First Last Prev Next    No search results available
Details
: [llvmg++] Dynamically initialized constants cannot be mar...
Bug#: 204
: tools
: llvm-g++
Status: RESOLVED
Resolution: FIXED
: All
: All
: 1.0
: P2
: normal
: 1.2

:
: miscompilation
:
:
  Show dependency tree - Show dependency graph
People
Reporter: Chris Lattner <sabre@nondot.org>
Assigned To: Chris Lattner <sabre@nondot.org>

Attachments


Note

You need to log in before you can comment on or make changes to this bug.

Related actions


Description:   Opened: 2004-01-11 17:46
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
------- Comment #1 From Chris Lattner 2004-01-11 23:12:02 -------
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

First Last Prev Next    No search results available