| Issue |
115718
|
| Summary |
[clang] false diagnostic when expanding two packs simultaniously in nested variadic lambda: `error: a non-type template parameter cannot have type 'auto'`
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
r-braun
|
clang trunk (`20.0.0` at the point of reporting this issue) fails to compile the following code in C++20 mode with `error: a non-type template parameter cannot have type 'auto'` ([Demo](https://godbolt.org/z/h9vq8aPeq)):
```c++
#include <utility>
template<auto V>
struct Constant{
static constexpr auto value = V;
};
template<auto... Vs>
struct Sequence{
template<class Func>
constexpr auto enumerate(Func = {}) {
[]<std::size_t... Is>(std::index_sequence<Is...>){
(Func{}(Constant<Vs>{}, Constant<Is>{}), ...);
}(std::make_index_sequence<sizeof...(Vs)>{});
}
};
int main() {
Sequence<0,1,2>{}.enumerate([](auto val, auto idx){
static_assert(val.value == idx.value);
});
}
```
The issue seems to stem from a combination of using an auto nttp and doing a simultanious pack-expansion with a nested pack introduced by a lambda that tries to instantiate said type.
The following variations compile succesfully:
- [use concrete type instead of auto for Constant](https://godbolt.org/z/xE1v4za56)
- [use concrete type instead of auto for Sequence](https://godbolt.org/z/deef5n4ar)
- [introduce the nested pack via the function instead of the lambda](https://godbolt.org/z/ndorhf1Ev)
- [pass a pre-instantiated pack of Constants into the lambda](https://godbolt.org/z/ra1Ghfaob)
In particular the last variation can currently be used as a drop in replacement, but makes the code a lot less clear IMO.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs