PR c++/90265 - ICE with generic lambda.
authorMarek Polacek <polacek@redhat.com>
Mon, 6 May 2019 16:56:39 +0000 (16:56 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 6 May 2019 16:56:39 +0000 (16:56 +0000)
* pt.c (tsubst_copy_and_build): Use a dedicated variable for the last
element in the vector.

* g++.dg/cpp1y/lambda-generic-90265.C: New test.

From-SVN: r270917

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/lambda-generic-90265.C [new file with mode: 0644]

index d9b7d2bb36ddfbf9d87bbcdc98ef8b912bbf3c57..e974951dc525cdf42c3c503bf543015bb36b3e9d 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-06  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/90265 - ICE with generic lambda.
+       * pt.c (tsubst_copy_and_build): Use a dedicated variable for the last
+       element in the vector.
+
 2019-05-03  Martin Liska  <mliska@suse.cz>
 
        * call.c (build_aggr_conv): Use is_empty instead of
index 3e8c70b0d154537d57d09238626c83291d89dfe0..2f2066e297cf5aeccbd94022eb1cca6a3177e817 100644 (file)
@@ -18881,7 +18881,8 @@ tsubst_copy_and_build (tree t,
            if (thisarg)
              {
                /* Shift the other args over to make room.  */
-               vec_safe_push (call_args, (*call_args)[nargs-1]);
+               tree last = (*call_args)[nargs - 1];
+               vec_safe_push (call_args, last);
                for (int i = nargs-1; i > 0; --i)
                  (*call_args)[i] = (*call_args)[i-1];
                (*call_args)[0] = thisarg;
index 679ac800828f12adfc13c51348ae96f01906146a..1ffdb10d4324e4a5b65cf64a53a2d4b6fd2688fc 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-06  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/90265 - ICE with generic lambda.
+       * g++.dg/cpp1y/lambda-generic-90265.C: New test.
+
 2019-05-06  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/90358
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-90265.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-90265.C
new file mode 100644 (file)
index 0000000..d9ab9b7
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/90265
+// { dg-do compile { target c++14 } }
+
+void (*a)(int, int, int, void *) = [](auto, auto, auto, auto) {};