[LLVMbugs] [Bug 8409] New: clang++ generates incorrect code for initializers of static members of class templates
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Oct 18 08:26:06 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=8409
Summary: clang++ generates incorrect code for initializers of
static members of class templates
Product: clang
Version: 2.8
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: richard-llvm at metafoo.co.uk
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
Created an attachment (id=5633)
--> (http://llvm.org/bugs/attachment.cgi?id=5633)
Testcase
Normally, when a class has a static member, no guard variable is needed to
prevent multiple initialization since the member can only be defined once.
However, if the class is a class template instance, then the member is
permitted to be defined multiple times (C++ 2003 3.2p5), and the compiler must
insert a guard variable to prevent multiple initialization (and hence multiple
destruction). But clang++ does not do this.
A testcase is attached; compile it with and without -DMAIN, and link the two
object files together. This should result in precisely one call to the K
constructor. However, clang++ calls the K constructor twice (at the same
address), and calls the K destructor twice on exit (again at the same address).
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list