This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/51900] [4.6 Regression] const variable initialization always zero
- From: "daniel.f.starke at freenet dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 19 Jan 2012 14:51:33 +0000
- Subject: [Bug target/51900] [4.6 Regression] const variable initialization always zero
- Auto-submitted: auto-generated
- References: <bug-51900-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51900
--- Comment #5 from Daniel Starke <daniel.f.starke at freenet dot de> 2012-01-19 14:51:33 UTC ---
Compiling it with
gcc -static -fcommon -o main.o -c main.c
gcc -static -fcommon -o a.o -c a.c
gcc -static -o main.exe main.o a.o
results in
$ ./main
myVar[0] = 5
myVar[1] = 6
myVar[2] = 7
Compiling it with
gcc -static -O2 -fcommon -o main.o -c main.c
gcc -static -O2 -fcommon -o a.o -c a.c
gcc -static -o main.exe main.o a.o
results in
$ ./main
myVar[0] = 0
myVar[1] = 0
myVar[2] = 0
Thus a different option causes this change.