When I compile following code with -O2 -m32 -S -fno-strict-aliasing -fno-unrolling -fno-builtin. GCC seems to be not respecting -fno-strict-aliasing. I don't encounter this issue in gcc-4.8. struct list { int hd; struct list * tl; }; struct list * reverselist (struct list * l) { struct list * r, * r2; for (r = NULL; l != NULL; l = l->tl) { r2 = mymalloc(sizeof(struct list)); r2->hd = l->hd; r2->tl = r; r = r2; } return r; } The issue is that statement A precedes B. It is fine in gcc-4.8.4. Assembly gcc-4.1.0: movl (%ebx), %eax # <variable>.hd, <variable>.hd movl %esi, 4(%edx) # r, <variable>.tl movl %edx, %esi # D.3244, r A: movl 4(%ebx), %ebx # <variable>.tl, l B: movl %eax, (%edx) # <variable>.hd, <variable>.hd testl %ebx, %ebx # l Assembly gcc-4.8.4: movl (%ebx), %edx # l_16->hd, D.5537 movl %esi, 4(%eax) # r, r_7->tl movl %edx, (%eax) # D.5537, r_7->hd movl 4(%ebx), %ebx # l_16->tl, l testl %ebx, %ebx # l
Did you mean gcc-5.1.0?
(In reply to Andreas Schwab from comment #1) > Did you mean gcc-5.1.0? No. It is for gcc-4.1.0 :) We were checking for equivalence of code generated across different versions and found this bug. We saw that it is possible to file bug reports for earlier versions so we filed it.
(In reply to Manjeet Dahiya from comment #2) > (In reply to Andreas Schwab from comment #1) > > Did you mean gcc-5.1.0? > > No. It is for gcc-4.1.0 :) We were checking for equivalence of code > generated across different versions and found this bug. We saw that it is > possible to file bug reports for earlier versions so we filed it. The reason we tested gcc-4.1.0 was that it is still being used for development of some of our tools.
4.1 is no longer support and has not been for over 5 years now. Closing as won't fix. There was some known issues in pre GCC 4.7 where aliasing was broken (there are a few bug reports already closed about it).