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: "reza dot yazdani at amd dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Feb 2010 23:14:40 -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 #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