This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/35501] Wrong value returned from const int
- From: "matz at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 May 2008 15:13:00 -0000
- Subject: [Bug tree-optimization/35501] Wrong value returned from const int
- References: <bug-35501-682@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from matz at gcc dot gnu dot org 2008-05-08 15:13 -------
Hmm, actually I sort of agree with HJ. It's a global (and unhidden)
definition, which very well can be replaced by a different definition at
runtime. In particular that will happen for instance if the global data
is defined in a shared lib, but referenced from the executable. A COPY reloc
will be created and the content of the variable will be taken from the
executable. That of course will have the same value as in the shared lib,
so that difference doesn't matter.
The only way by which we could declare the current behaviour valid, is if
we declare several definitions of global const variables with different
value as invalid. The C standard isn't concerned with different shared
object, so we can't extract such declaration out of it. The ELF standard
doesn't say anything about this, so the default rules apply, which would
require _not_ hardcoding the constant.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35501