Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

eagerly-instantiated entities whose templates are defined after the first point of instantiation don't get instantiated at all #24127

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR24128
Status NEW
Importance P normal
Reported by Richard Smith (richard-llvm@metafoo.co.uk)
Reported on 2015-07-14 20:24:46 -0700
Last modified on 2021-06-02 22:13:11 -0700
Version trunk
Hardware PC Linux
CC dblaikie@gmail.com, dgregor@apple.com, ldalessandro@gmail.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
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.
Quuxplusone commented 7 years ago

_Bug 16008 has been marked as a duplicate of this bug._

Quuxplusone commented 3 years ago

_Bug 50207 has been marked as a duplicate of this bug._