The following four little pieces should give identical results: $gcc test.c; ./a.out -2, -2, -2 , -2, 0, -2 -2, -2, -2 , -2, 0, -2 -2, -2, -2 , -2, 0, -2 -2, -2, -2 , -2, 0, -2 but they dont: gcc test.c; ./a.out -2, -2, -2 , -2, 0, -2 -4, -2, -2 , -2, 0, -2 -2, -2, -2 , -2, 0, -2 -2, -2, -2 , -2, 0, -2 $cat test.c void main(void) { int a, b, c, x, y, z, A, B, C, X, Y, Z; a=-2; b=-2; c=-2; x=-2; y=-2; z=-2; (y -= b); (c ? a : b) += (x ? y : z); printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z); /*------------------------------------------------------------------*/ a=-2; b=-2; c=-2; x=-2; y=-2; z=-2; ( (y -= b) ? (c ? a : b) : (c ? a : b) ) += (x ? y : z); printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z); /*------------------------------------------------------------------*/ a=-2; b=-2; c=-2; x=-2; y=-2; z=-2; ( (y -= b) ? ((c ? a : b) += (x ? y : z)) : ((c ? a : b) += (x ? y : z)) ); printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z); /*------------------------------------------------------------------*/ a=-2; b=-2; c=-2; x=-2; y=-2; z=-2; ( (y -= b) ? ((c ? (a += (x ? y : z)) : (b += (x ? y : z)))) : ((c ? (a += (x ? y : z)) : (b += (x ? y : z)))) ); printf("%d, %d, %d , %d, %d, %d\n", a, b, c, x, y, z); } Release: 2.95.3 20010315 (SuSE), 3.1 Environment: Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.3/specs gcc version 2.95.3 20010315 (SuSE) or Reading specs from /pkg/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.1/specs Configured with: ../configure --prefix=/pkg/gnu --enable-languages=c++,f77 Thread model: posix gcc version 3.1 How-To-Repeat: just compile and run: $gcc test.c; ./a.out
State-Changed-From-To: open->closed State-Changed-Why: Not a bug. There is no sequence point across an assignment operator.
Reopening to mark as a duplicate of...
...PR 11751. *** This bug has been marked as a duplicate of 11751 ***