const int i=0; int foo(void) { *(int *)&i = 1; return i; }
with -O0 gcc returns 1, with -O1 and up it returns 0. Is this a valid store to i? If not, why doesn't gcc warn even at -Wall? -- Summary: write to const variable ignored at -O[12] Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rguenth at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21569