value of the constant expression 1<<(1?1:1) < 0x9999
- From: Francois Grieu <fgrieu@xxxxxxxxx>
- Date: Tue, 29 Apr 2008 15:03:04 -0700 (PDT)
Hello,
one of my C compiler (Keil C51) evaluates the constant expression
1<<(1?1:1) < 0x9999
to the value 1.
// this returns 0, much to my surprise
unsigned char bug4_a(void)
{
return 1<<(1?1:1) < 0x9999;
}
Can this find a satisfactory explanation under some definition of the
C language ?
Note: I still get 0 for
return 1<<(1?1:1) < (unsigned)0x9999;
return 1<<(unsigned char)(1?1:1) < 0x9999;
but I get 1 (as I expect) for
return 1<<(1) < 0x9999;
return (unsigned)1<<(1?1:1) < 0x9999;
return 1u<<(1?1:1) < 0x9999;
return 1<<(1?1:1) < 0x7777;
return 1<<(1?1:1) == 2;
#if 1<<(1?1:1) < 0x9999
return 1;
#else
return 0;
TIA,
Francois Grieu
.
- Follow-Ups:
- Re: value of the constant expression 1<<(1?1:1) < 0x9999
- From: Francois Grieu
- Re: value of the constant expression 1<<(1?1:1) < 0x9999
- From: Keith Thompson
- Re: value of the constant expression 1<<(1?1:1) < 0x9999
- From: Peter Nilsson
- Re: value of the constant expression 1<<(1?1:1) < 0x9999
- Prev by Date: Re: 128 bit integer code needed
- Next by Date: Re: value of the constant expression 1<<(1?1:1) < 0x9999
- Previous by thread: Why this program fails for larger input value ?
- Next by thread: Re: value of the constant expression 1<<(1?1:1) < 0x9999
- Index(es):
Relevant Pages
|