lkml.org 
[lkml]   [2001]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [BUG] Bad #define, nonportable C, missing {}


On Thu, 22 Nov 2001, Horst von Brand wrote:

> Stevie O <stevie@qrpff.net> said:

> > But x++ is postincrement though. That means the value of 'x' is inserted,
> > and after the expression is evaluated, x is incremented. Right?
>
> Nope. x++ increments x sometime (not defined when) after taking the value.
>
> x = x++ % y
>
> is wrong: There is just one sequence point at the end of the expression,
> and x is modified twice in between (++ and =).

Or look at it that way: both
tmp = x % y; x++; x = tmp;
and
tmp = x % y; x = tmp; x++;
are possible interpretations with different results. And as usual, compiler
is allowed to do literally anything whenever it sees such beast.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:13    [W:0.056 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site