GCC's statement expression extension

sidster patrick@mail.boxsoft.com
Fri Jul 28 13:33:00 GMT 2000


* Anjul Srivastava (anjul.srivastava@sanchez.com) [20000728 12:13]:
> It does not have undefined behavior, and will always evaluate to: three plus
> twice the old value of i.
> 
> But that's besides the point. Even if you consider: ++i + i++ the behavior
> is undefined,
> 
> but it cannot format your hard disk and still remain conforming. It cannot
> ever return 42, regardless of the value of i. (It can only return an odd
> integer but this again is besides the point).


Of course it can:

   i = 20;

   n = ++i + i++;

   // assume evaluation is from right to left
   //
   n = (21+1) + 20;  // n = 42




Best regards,

patrick
--
We've heard that a million monkeys at a million keyboards could
produce the Complete Works of Shakespeare; now, thanks to the
Internet, we know this is not true.
   -Robert Wilensky


More information about the Gcc mailing list