[LLVMbugs] [Bug 20156] New: Variable templates generate compiler warnings and linking errors
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Jun 28 10:26:12 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=20156
Bug ID: 20156
Summary: Variable templates generate compiler warnings and
linking errors
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++1y
Assignee: unassignedclangbugs at nondot.org
Reporter: chris.a.ferguson at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
The code below compiled with Clang 3.4 using `-std=c++1y -Wall -Wextra
-pedantic -O3` produces the following warning: variable 'M_PI<int>' has
internal linkage but is not defined [-Wundefined-internal]
#include <iostream>
template <typename T>
constexpr T M_PI = T(3.1415926535897932);
template <typename T>
constexpr T CalcCircumference(T d)
{
return d * M_PI<T>;
}
int main()
{
std::cout << CalcCircumference(42.0f);
}
Another example here:
template <typename T> T var = 0;
template <typename T> T func() { return var<T>; }
int main() { return func<int>(); }
$ clang++ test2.cc -o test2 -std=c++1y -pedantic -Wall
/tmp/test2-736968.o:test2.cc:function int func(): error: undefined reference to
'var'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--
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/20140628/d426bb09/attachment.html>
More information about the llvm-bugs
mailing list