Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > value of the co...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 25974 of 27343
Post > Topic >>

value of the constant expression 1<<(1?1:1) < 0x9999

by Francois Grieu <fgrieu@[EMAIL PROTECTED] > Apr 29, 2008 at 03:03 PM

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
 




 8 Posts in Topic:
value of the constant expression 1<<(1?1:1) < 0x9999
Francois Grieu <fgrieu  2008-04-29 15:03:04 
Re: value of the constant expression 1<<(1?1:1) < 0x9999
Peter Nilsson <airia@[  2008-04-29 15:35:06 
Re: value of the constant expression 1<<(1?1:1) < 0x9999
Keith Thompson <kst-u@  2008-04-29 15:53:38 
Re: value of the constant expression 1<<(1?1:1) < 0x9999
Peter Nilsson <airia@[  2008-04-29 16:13:21 
Re: value of the constant expression 1<<(1?1:1) < 0x9999
Keith Thompson <kst-u@  2008-04-29 16:36:20 
Re: value of the constant expression 1<<(1?1:1) < 0x9999
Francois Grieu <fgrieu  2008-04-29 21:00:21 
Re: value of the constant expression 1<<(1?1:1) < 0x9999
Francois Grieu <fgrieu  2008-04-29 21:32:20 
Re: value of the constant expression 1<<(1?1:1) < 0x9999
Francois Grieu <fgrieu  2008-04-29 21:36:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Sep 6 21:20:05 CDT 2008.