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 tree-optimization/35501] Wrong value returned from const int



------- Comment #5 from reza dot yazdani at amd dot com  2010-02-05 23:14 -------
"The optimization performed is correct because:

In C++ (not in C) a const modifier in a global variable has internal
linkage (i.e. it is treated like a static variable) and therefore the
optimization performed is correct. A global const variable can have
legally different values in different files.

In C, it is illegal to initialize a global variable in more than one
location, and if initialized in more than one place all values must be
the same, because its initial value is nondeterministic if different.

This bug is unrelated to PIC, it will behave the same, if the program is
written according to the C/C++ standards."

I suggest to be closed and marked as user error.


-- 

reza dot yazdani at amd dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reza dot yazdani at amd dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35501


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