[llvm-bugs] [Bug 26006] New: Undefined references to static const members of class templates (but not when const is omitted)
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Jan 3 01:44:04 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26006
Bug ID: 26006
Summary: Undefined references to static const members of class
templates (but not when const is omitted)
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: sisnkemp at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
Created attachment 15547
--> https://llvm.org/bugs/attachment.cgi?id=15547&action=edit
Test program to reproduce
The below program (also attached) produces an undefined reference to
Foo::Bar<int>::m when m is declared as const. Just compile it with clang++
test.cpp. It does not compile with the latest clang from the trunk, nor with
clang 3.5.
However, when m does not have any additional qualifiers or when m is declared
as const volatile, then the program compiles, links, and runs. You can verify
this by defining QUALS as empty or as "const volatile".
GCC compiles and links the program fine.
This code was distilled from xulrunner 24.8.0.
#define QUALS const
//#define QUALS const volatile
//#define QUALS
class Foo {
public:
template <typename T>
struct Bar {
static QUALS long m;
};
static QUALS long& getter() { return Bar<int>::m; }
static int f();
};
template <typename T>
QUALS long Foo::Bar<T>::m = 1;
int Foo::f()
{
return getter();
}
int main()
{
return Foo::f();
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160103/2bd2fc51/attachment.html>
More information about the llvm-bugs
mailing list