mrs $ cat /tmp/t2.cc typedef long GLint; void aglChoosePixelFormat(const GLint *);
void find(const int *alistp) { const int *blist; int list[32]; if (alistp) blist = alistp; else { list[3] = 42; /* this store disappears with -fstrict-aliasing */ blist = list; } aglChoosePixelFormat((GLint*)blist); } mrs $ ./xgcc -B./ -S -O1 /tmp/t2.cc -fno-strict-aliasing && grep 42 t2.s li r0,42 mrs $ ./xgcc -B./ -S -O1 /tmp/t2.cc -fstrict-aliasing && grep 42 t2.s mrs $ The store cannot be removed, as the converted pointer can be used inside the aglChoosePixelFormat function to access the value. Since the optimizer can't see that it isn't used, the optimizer must assume it can as the function isn't marked pure. If it had been, then the optimization would be ok. t2.cc.035t.dce1 is the first pass that doesn't have the store, t2.cc.034t.fre has the store. This worked in 3.3, but not 4.0.1. This doesn't work in gcc version 4.2.0 20060815 (experimental) on powerpc-apple-darwin9.0.0d1, nor on i686-apple-darwin8. -- Summary: strict-aliasing bug Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mrs at apple dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28778