[Bug tree-optimization/35501] Wrong value returned from const int

matz at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu May 8 15:13:00 GMT 2008



------- 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



More information about the Gcc-bugs mailing list