]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: ICE with lambda in fold expression in requires [PR119134]
authorMarek Polacek <polacek@redhat.com>
Fri, 7 Mar 2025 16:26:46 +0000 (11:26 -0500)
committerMarek Polacek <polacek@redhat.com>
Wed, 12 Mar 2025 17:35:49 +0000 (13:35 -0400)
The r12-8258 fix assumes that DECL_CONTEXT of 'pack' in
check_for_bare_parameter_packs is going to be an operator()
but as this test shows, it can be empty.

PR c++/119134

gcc/cp/ChangeLog:

* pt.cc (check_for_bare_parameter_packs): Check DECL_CONTEXT.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-uneval24.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp2a/lambda-uneval24.C [new file with mode: 0644]

index 6ac9e6f163ec5fe3802bcb352d9e825f83253163..8aaae44686871cfdc1d2a6ca556e4833e1df39c6 100644 (file)
@@ -4375,6 +4375,7 @@ check_for_bare_parameter_packs (tree t, location_t loc /* = UNKNOWN_LOCATION */)
        tree pack = TREE_VALUE (parameter_packs);
        if (is_capture_proxy (pack)
            || (TREE_CODE (pack) == PARM_DECL
+               && DECL_CONTEXT (pack)
                && DECL_CONTEXT (DECL_CONTEXT (pack)) == lam))
          break;
       }
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-uneval24.C b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval24.C
new file mode 100644 (file)
index 0000000..a2b4559
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/119134
+// { dg-do compile { target c++20 } }
+
+void f(auto... args) requires(([args] {}, ..., true)) {}