This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/58270] Wrong code while accessing array elements in a global structure
- From: "strasbur at chkw386 dot ch.pwr.wroc.pl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 29 Aug 2013 13:32:47 +0000
- Subject: [Bug c/58270] Wrong code while accessing array elements in a global structure
- Auto-submitted: auto-generated
- References: <bug-58270-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58270
--- Comment #8 from Krzysztof Strasburger <strasbur at chkw386 dot ch.pwr.wroc.pl> ---
Mikael,
I cannot agree. Do not look at main.c, as the compiler doesn't know anything
about it while compiling buggy.c (this is the reason for which I keep main()
separately) and doesn't know that i1, i2 and i3 may be set to something > 0 at
runtime.
If it would be so much strict about declarations, it wouldn't also allow to
modify mem.dmem[1] - everything would go into mem.dmem[0].
However, it writes mem.dmem[1] only (!) if compiled without -fno-tree-dse and
mem.dmem[0] plus mem.dmem[1] with -fno-tree-dse.
The problem is that the compiler does not work predictably. BTW, correct size
of the mem structure (global variable) is ensured by the linker:
$ nm buggy.o
00000000 T buggy
0000000c C loc
00000008 C mem
I would also expect that if the compiler is instructed explicitly to release
some constraints, then these will be released.