[clang] [Clang] Diagnose unexpanded packs for NTTP type constraints (PR #121296)

via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 30 02:21:35 PST 2024


================
@@ -305,3 +305,45 @@ static_assert(__is_same_as(_Three_way_comparison_result_with_tuple_like<tuple<in
 static_assert(__is_same_as(_Three_way_comparison_result_with_tuple_like<tuple<int>, 0>::type, long));
 
 }
+
+namespace GH88866 {
+
+template <typename...Ts> struct index_by;
+
+template <typename T, typename Indices>
+concept InitFunc = true;
+
+namespace Invalid {
+
+template <typename Indices, InitFunc<Indices> auto... init>
+struct LazyLitMatrix;
+
+template <
+    typename...Indices,
+    InitFunc<index_by<Indices>> auto... init
+    // expected-error at -1 {{type constraint contains unexpanded parameter pack 'Indices'}}
----------------
cor3ntin wrote:

Why do you think this is invalid?
https://eel.is/c++draft/temp.variadic#6.4.1

I expect it to be equivalent to

```cpp
template <
    typename...Indices,
    InitFunc<index_by<Indices...[0]>> auto init,
    InitFunc<index_by<Indices...[1]>> auto init1
>
struct LazyLitMatrix<index_by<Indices...>, init, init1>
```
(GCC accepts this code)


https://github.com/llvm/llvm-project/pull/121296


More information about the cfe-commits mailing list