Hello,
I’m new to clang development and was hoping to get some help in tackling this bug that I found/filed: http://llvm.org/bugs/show_bug.cgi?id=20625
Example:
template
void F() {
struct Num {
static constexpr int Get() { return 42; }
};
constexpr int n = Num::Get();
}
int main() {
F();
}
The summary of the issue is that the local struct Num and its static constexpr function Get is not yet instantiated when we validate the constexpr variable initialization of n during F’s instantiation.
More details:
Num and Get gets added to PendingLocalImplicitInstantiations in SubstStmt at SemaTemplateInstantiationDecl.cpp:3437, and is instantiated later by PerformPendingInstantiations at SemaTemplateInstantiationDecl.cpp:3458. However, the validation of the constexpr variable initialization of n happens in SubstStmt at which point we don’t yet have the definition of Get instantiated.
I’m not exactly sure what the correct approach would be to solve the problem. It seems that the local implicit instantiations need to be performed earlier, or the validation of constexpr variables need to be delayed.
If someone can point me in the right direction it would be appreciated.
Thanks,
Michael Park