the prefix increment operator is not correctly evaluated in the following code: int a[8]; int i = 4; a[i] = ++i; the last line is evaluated as a[4] = 5; instead of a[5] = 5; Release: 2.95-2, 2.95-3, 2.96, 3.0.1 20010620 Environment: mingw port (2.95-2, 2.95-3), RedHat Linux 7.1 gcc compiler (2.96-??), CodeSourcery online test compilation(3.0.1 20010620 ) How-To-Repeat: void test(void) { int a[8] = {0,0,0,0,0,0,0,0}; int i = 4; a[i] = ++i; printf("\na[4] = %d\na[5] = %d\n", a[4], a[5]); }
State-Changed-From-To: open->closed State-Changed-Why: This is not a bug - your code has undefined behaviour as there is no sequence point between the two uses.
Reopening to ...
Mark as a dup of bug 11751. *** This bug has been marked as a duplicate of 11751 ***