increasing var twice in a statement
jlh
jlh@gmx.ch
Fri Jun 15 15:27:00 GMT 2007
> Can anybody tell me what output the following program snippet
> should produce according to C standard:
I think this case produces undefined behavior, so by the C
standard, 9 would be as correct as 10 or 42. Compiling your code
with "-O2 -Wall" even produces a warning:
a.c:5: warning: operation on 'b' may be undefined
The reason is that you're modifying a variable twice within the
same two sequence points. See
http://en.wikipedia.org/wiki/Sequence_point
jlh
More information about the Gcc-help
mailing list