This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/58270] Wrong code while accessing array elements in a global structure


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]