[llvm-bugs] [Bug 28816] New: Missing error on explicit instantiation definition of undefined variable template
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Aug 2 05:57:00 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28816
Bug ID: 28816
Summary: Missing error on explicit instantiation definition of
undefined variable template
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++14
Assignee: unassignedclangbugs at nondot.org
Reporter: john.brawn.123 at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
In the following example:
template<int n> int var;
template int var<0>;
We have the declaration of a variable template, then an explicit instantiation
definition of a specialization of that template.
C++14 section 14.7.2 paragraph 5 says
For a given set of template arguments, if an explicit instantiation of a
template appears after a declaration
of an explicit specialization for that template, the explicit instantiation
has no effect. Otherwise, for an
explicit instantiation definition the definition of a function template, a
variable template, a member function
template, or a member function or static data member of a class template
shall be present in every translation
unit in which it is explicitly instantiated.
Here there is no declaration of an explicit specialization for the template, so
there must be a definition of the template. As there is not we must emit an
error. Instead clang appears to just ignore the explicit instantiation
definition. If we try to do the same thing with another kind of template, e.g.:
template<int n> int fn();
template int fn<0>();
then we correctly get an error:
tmp.cpp:5:14: error: explicit instantiation of undefined function template
'fn'
template int fn<0>();
^
--
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/20160802/9eea7d81/attachment.html>
More information about the llvm-bugs
mailing list