Bugzilla – Bug 204
[llvmg++] Dynamically initialized constants cannot be marked 'constant'
Last modified: 2004-01-11 23:12:02
You need to log in before you can comment on or make changes to this bug.
The C++ front-end is currently marking globals 'constant' if they are constant in the source language. However, in C++, some constant initializers cannot be computed statically, so dynamic initializers are emitted. In this case, the value is modified at runtime, so the global cannot be marked as an LLVM constant. Testcase: --- extern int X; const int Y = X; const int* foo() { return &Y; } --- The pertinent output: --- ... %Y = internal constant int 0 ;;; Should not be marked as 'constant'! ... store int %tmp.4.i, int* %Y ... --- Fixing this is just a matter of figuring out how GCC encodes this condition. -Chris
This bug is now fixed. Testcase here: Regression/C++Frontend/2004-01-11-DynamicInitializedConstant.cpp.tr Patch here: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040105/010678.html -Chris