[LLVMbugs] [Bug 502] NEW: [llvm-g++] llvm-g++ unsafely marks 'const' global variable prototypes as readonly
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Fri Feb 11 15:29:11 PST 2005
http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=502
Summary: [llvm-g++] llvm-g++ unsafely marks 'const' global
variable prototypes as readonly
Product: tools
Version: 1.0
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: llvm-g++
AssignedTo: unassignedbugs at nondot.org
ReportedBy: sabre at nondot.org
Consider this code:
---
struct foo { int X; };
struct bar {
static const foo FFF;
};
extern const int Y;
const foo *XXX = &bar::FFF;
const int* Yp = &Y;
---
llvm-g++ compiles this to the following code:
-----
%struct.foo = type { int }
%XXX = global %struct.foo* %_ZN3bar3FFFE
%_ZN3bar3FFFE = external constant %struct.foo
%Yp = global int* %Y
%Y = external constant int
-----
Note that "XXX" and "Y" are both marked as being constant. This is illegal in
C++, because the variables could require dynamic initialization, e.g. if they
are defined like this:
const int Y = foo();
In C++, the definition has to indicate the constness, the declaration cannot do it.
-Chris
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list