In this testcase: inline int foo() { static int X = 0; return ++X; } int bar() { return foo(); } The LLVM global variable declaration for the X variable should have "linkonce", not "weak" linkage. It is not clear how to get this information from the GCC front-end.
Just to be perfectly clear here: this does not cause incorrect compilation at all. This just prevents the LLVM optimizers from deleting the variable when it is unreferenced in a translation unit.
A question about this has now been asked on the GCC list: http://gcc.gnu.org/ml/gcc/2003-10/msg01272.html
More analysis is available here: http://gcc.gnu.org/ml/gcc/2003-10/msg01292.html Fixing this bug is critical for compiling reasonably sized C++ translation units, so I'm upgrading it's severity to 'normal', and targetting it to 1.1.
This has now been fixed by 'ifdef'ing out the "win32" specific case in this post: http://gcc.gnu.org/ml/gcc/2003-10/msg01309.html -Chris
New testcase for another form of this problem: test/Regression/C++Frontend/2003-11-02-WeakLinkage.cpp.tr This instance of the bug has also been fixed in the CFE now.