Open ilya-biryukov opened 3 months ago
@llvm/issue-subscribers-clang-frontend
Author: Ilya Biryukov (ilya-biryukov)
After the PRs referenced in the issue, there is one more example that I came up with that still breaks and will need another follow up: unexpanded packs in C++20 constraints used in the template parameter list of a lambda expression: https://gcc.godbolt.org/z/T7ea68rME
template <int ...x>
int Cartesian3(auto y) {
return [&]<int ...xs>(Ints<xs...>) {
// check in default template arguments for
// - requirements of type template parameters,
return (apply([]<LessThan<xs> = IntValue<0>>(auto... ys) {
return (ys + ...);
}, y) + ...);
}(Ints<x...>());
}
On this code:
Clang will crash with a following assertion error:
The problem arises because when substituting into inner lambdas, Clang will incorrectly loose the
ContainsUnexpandedPack
dependency on a lambda expression. In turn, this confuses theCXXFoldExpr
that relies in this flag to distinguish left and right folds, which will pass thenullptr
expr toCollectUnexpandedParameterPacks
and cause it to not find any packs when transforming the fold expression, leading to an asssertion.I have already been working on a fix for a few days and more sophisticated tests, so assigning to myself right away.