This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: A simple question on expression


On Fri, Aug 31, 2001 at 03:22:41PM +0800, Jie Zhang wrote:

> I want to ask a simple question on expression.
[...]
> a = (a<4)?0:a++; /* 1 */
[...]
> Who can tell me why the two printfs print out different results?
that is obvious!

second expression ([1]) is undefined -- it expands to:
if (a<4)
	a=0;
else
	a=a++; /* 2 */

[2] is undefined -- i.e a can take whatever possible value after it.
Please, read K&R before asking such questions.


-- 
They finally got King Midas, I hear.  Gild by association.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]