-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Assertion failure with nested parameter packs and lambdas #61460
Comments
Confirmed: #57082 |
@llvm/issue-subscribers-clang-frontend |
Clicking through the godbolt link shows this still repros. |
Upon some investigation on this issue, I'd say removing all assertions of non-empty The crash happens in llvm-project/clang/lib/Sema/SemaTemplateVariadic.cpp Lines 397 to 409 in eca2fcb
This is suspicious since we've validated that llvm-project/clang/include/clang/AST/ExprCXX.h Lines 4481 to 4495 in eca2fcb
Looking through the stack, we'd find that the llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp Lines 2102 to 2105 in eca2fcb
(which invokes llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp Lines 2067 to 2076 in eca2fcb
(which transforms template <typename... Ts> void g(Ts... p1s) {
(void)[&](auto... p2s) { ([&] { p1s; }, ...); };
}
void f1() {
g();
} then we won't be building a So, one way that occurs to me is to add the (missing) llvm-project/clang/lib/Sema/SemaTemplateVariadic.cpp Lines 30 to 31 in eca2fcb
bool VisitFunctionParmPackExpr(FunctionParmPackExpr *Pack) {
addUnexpanded(Pack->getParameterPack(), Pack->getParameterPackLocation());
return true;
} I patched this collector locally, and indeed it solved the crash. But unfortunately, this immediately crashes the test case auto v = [](auto ...a) {
[&](auto ...b) {
((a = b), ...);
}(100, 20, 3);
return (a + ...);
}(400, 50, 6); This time, I'm hitting the assertion inside For this reason, we might have to accept some discrepancies inside The other reason that makes this plausible is, that although we've affirmed non-empty llvm-project/clang/lib/Sema/SemaTemplateVariadic.cpp Lines 291 to 295 in eca2fcb
|
Proposed fix: #69224 |
…armPackExpr Closes llvm#61460. We have FunctionParmPackExpr that serves as the unexpanded expression but from which the visitor collects none, which may lead to assertion failure during the template instantiation.
…ndedParameterPacksVisitor Closes llvm#61460. We have FunctionParmPackExpr that serves as unexpanded pack expressions but from which the visitor collects none, which leads to the assertion failure during the template instantiation. Actually, we don't need to assert this condition since we would do nothing in the subsequent DiagnoseUnexpandedParameterPacks call even if unsatisfied.
…armPackExpr (llvm#69224) Closes llvm#61460. We have FunctionParmPackExpr that serves as the unexpanded expression but from which the visitor collects none, which may lead to assertion failure during the template instantiation.
https://godbolt.org/z/4Pj4GhY9s
Looks like (according to GCC and Clang without assertions) this is probably valid (though I'm not entirely sure how/why - not sure how the lambda pack applies/doesn't to the function template pack)
The crash backtrace is:
The text was updated successfully, but these errors were encountered: