<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Variable templates generate compiler warnings and linking errors"
href="http://llvm.org/bugs/show_bug.cgi?id=20156">20156</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Variable templates generate compiler warnings and linking errors
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++1y
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>chris.a.ferguson@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>