Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zygoloid mannequin opened this issue Jul 15, 2015 · 5 comments
Labels
bugzilla Issues migrated from bugzilla c++

Comments

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Jul 15, 2015

Bugzilla Link 24128
Version trunk
OS Linux
CC @dwblaikie,@DougGregor,@ldalessa

Extended Description

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 struct X { static const int n; };
int k = X::n;
template const int X::n = 5;

// C++11:
template constexpr int f();
int k = f();
template constexpr int f() { return 5; }

// C++14:
template extern const int n;
int k = n;
template 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.

@zygoloid
Copy link
Mannequin Author

zygoloid mannequin commented Oct 21, 2016

*** Bug #16380 has been marked as a duplicate of this bug. ***

@zygoloid
Copy link
Mannequin Author

zygoloid mannequin commented Jun 2, 2021

*** Bug llvm/llvm-bugzilla-archive#50207 has been marked as a duplicate of this bug. ***

@zygoloid
Copy link
Mannequin Author

zygoloid mannequin commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#50207

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@jwakely
Copy link
Contributor

jwakely commented Dec 12, 2021

I think this is causing problems for constexpr std::string in libstdc++:
https://gcc.gnu.org/pipermail/libstdc++/2021-December/053605.html

@jwakely
Copy link
Contributor

jwakely commented Jan 4, 2022

*** Bug llvm/llvm-bugzilla-archive#50207 has been marked as a duplicate of this bug. ***

That is #49551 in new money.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++
Projects
None yet
Development

No branches or pull requests

1 participant