This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/21569] New: write to const variable ignored at -O[12]
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 May 2005 14:22:13 -0000
- Subject: [Bug tree-optimization/21569] New: write to const variable ignored at -O[12]
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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