Different behaviours with different compilers
here is a segment of C code
int i = 0;
printf("%d %d\n", i, i++);
outputs from different compilers
gcc version 3.4.2 [FreeBSD] 20040728
1 0
M$ VC++ .Net 2003
1 0
Intel C++ Compiler version 8.1.479.2003
1 0
M$ VC++ 6.0
0 0


1 Comments:
IS0/IEC 9899:1999 (E)
7.24.2 Formatted wide character input/output functions
1 The formatted wide character input/output functions shall behave as if there is a sequence point after the actions associated with each specifier.
Seems gcc execute the last argument first, while VC executes the first argument first.
Post a Comment
<< Home