From cd0a831ce6d6fe9ff14959b0602ad7deed6d2785 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 6 May 2019 16:56:39 +0000 Subject: [PATCH] PR c++/90265 - ICE with generic lambda. * 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 | 6 ++++++ gcc/cp/pt.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/lambda-generic-90265.C | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-90265.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d9b7d2bb36d..e974951dc52 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-05-06 Marek Polacek + + 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 * call.c (build_aggr_conv): Use is_empty instead of diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3e8c70b0d15..2f2066e297c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 679ac800828..1ffdb10d432 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-05-06 Marek Polacek + + PR c++/90265 - ICE with generic lambda. + * g++.dg/cpp1y/lambda-generic-90265.C: New test. + 2019-05-06 Richard Biener 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 index 00000000000..d9ab9b7f55f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-90265.C @@ -0,0 +1,4 @@ +// PR c++/90265 +// { dg-do compile { target c++14 } } + +void (*a)(int, int, int, void *) = [](auto, auto, auto, auto) {}; -- 2.30.2