[LLVMbugs] [Bug 24128] New: eagerly-instantiated entities whose templates are defined after the first point of instantiation don't get instantiated at all
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jul 14 18:24:46 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24128
Bug ID: 24128
Summary: eagerly-instantiated entities whose templates are
defined after the first point of instantiation don't
get instantiated at all
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: richard-llvm at metafoo.co.uk
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
If a template specialization is referenced in a way that requires a definition,
but the definition of the template appears after the use, the instantiation is
never performed.
Examples through the ages:
// C++98:
template<typename T> struct X { static const int n; };
int k = X<int>::n;
template<typename T> const int X<T>::n = 5;
// C++11:
template<typename T> constexpr int f();
int k = f<int>();
template<typename T> constexpr int f() { return 5; }
// C++14:
template<typename T> extern const int n;
int k = n<int>;
template<typename T> const int n = 5;
These are valid, and should cause the instantiation of the relevant template,
according to C++14 [temp]/6, which requires the template to "be defined in
every translation unit in which it is implicitly instantiated", but doesn't
require the definition to precede the use.
--
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/20150715/19c459ea/attachment.html>
More information about the llvm-bugs
mailing list