This test case fails for GCC 3.3.x and GCC 3.4.x at any level of optimization other than -O0: extern void abort (void); char buffer[20]; void foo (char *p, const char *q) { int i = 0; while (q[i]) p[i] = q[i++]; } int main () { foo (buffer, "howdy"); if (buffer[0] != 'h') abort (); return 0; } I've tried it on powerpc64-linux and i686-linux and it fails on both. It doesn't fail with Red Hat's GCC 3.2.2-5 compiler (I don't have an FSF 3.2 compiler built anywhere), and doesn't fail with GCC 4.0.0 or GCC mainline.
A workaround is to replace the body of the loop with: { p[i] = q[i]; i++; }
This is invalid, there is no sequence point between the access of i and the increment of i so either can be first. With -W -Wall we get a warning: t.c:8: warning: operation on `i' may be undefined *** This bug has been marked as a duplicate of 11751 ***