-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Pack indexing expression is not being instantiated #121242
Comments
CC @cor3ntin |
@llvm/issue-subscribers-clang-frontend Author: None (Eczbek)
Compiler Explorer: https://godbolt.org/z/TG4hMMPv3
template<int... x>
int y = x...[0];
int main() {
y<0>;
}
|
It’s not that we're missing an instantiation for y<0>, but rather that we checked the initialization too early, right after the variable template was constructed. This is because the first PackIndexingExpr was assigned a ValueInstantiation dependency but retained a dependent type, which caused the logic to be skipped. llvm-project/clang/lib/Sema/SemaInit.cpp Lines 6431 to 6435 in 48bf0a9
llvm-project/clang/lib/AST/ExprCXX.cpp Lines 1722 to 1725 in 48bf0a9
We should probably set the expr type to This also indicates that a workaround is to convert the NTTP to a dependent type, i.e. the following would bypass the initialization check that happens before we see template<auto... x>
int y = x...[0];
int main() {
y<0>;
} |
Compiler Explorer: https://godbolt.org/z/TG4hMMPv3
The text was updated successfully, but these errors were encountered: