<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/115718>115718</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] false diagnostic when expanding two packs simultaniously in nested variadic lambda: `error: a non-type template parameter cannot have type 'auto'`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          r-braun
      </td>
    </tr>
</table>

<pre>
    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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVk1v4zYT_jX0ZRBBpvx58CGx1y9yeNECLfYajKhRxIYitfxwkv31xVC27KRbYBeoIcgChzPzzNdDYgj62RLtxPJBLA8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