[LLVMbugs] [Bug 502] [llvm-g++] Link failure linking 'const' global with a dynamic initializer

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Feb 12 11:35:49 PST 2005


sabre at nondot.org changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
            Summary|[llvm-g++] llvm-g++ unsafely|[llvm-g++] Link failure
                   |marks 'const' global        |linking 'const' global with
                   |variable prototypes as      |a dynamic initializer
                   |readonly                    |

------- Additional Comments From sabre at nondot.org  2005-02-12 13:35 -------
This bug took some thinking and pondering to get right, and required revisiting
some of the decisions made when we fixed Bug 450.  The problem with the
resolution for Bug 450 is that *any* const global in C++ can have a dynamic
initializer, not just those of class type with ctors (e.g. "const int X = foo();").

The solution to this problem is to generalize what LLVM allows for constants, as
documented in this patch:

To match these semantics, the linker was modified to permit this flexibility:

And some tests were added to check that this behavior continues to work:

Finally, the C++ front-end is now free to mark const global declarations as
constant even if the global variables have constructors.  This will perhaps lead
to better optimization of C++ programs.  Patch here:


This should fix the problem that prevented QT 4.0 from linking.


------- 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