From 8cb7aaa11b356fbebd63f6da60356f91e67e6217 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 13 Feb 2017 17:31:12 -0500 Subject: [PATCH] PR c++/79461 - ICE with lambda in constexpr constructor * constexpr.c (build_data_member_initialization): Ignore initialization of a local variable. From-SVN: r245410 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/constexpr.c | 3 +++ gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C | 10 ++++++++++ 3 files changed, 19 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 994492be7d9..3d840c5e12f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-02-13 Jason Merrill + + PR c++/79461 - ICE with lambda in constexpr constructor + * constexpr.c (build_data_member_initialization): Ignore + initialization of a local variable. + 2017-02-13 Jakub Jelinek * init.c (warn_placement_new_too_small): Add missing space in diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index bfdde9e911d..004bb45b87e 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -379,6 +379,9 @@ build_data_member_initialization (tree t, vec **vec) if (TREE_CODE (member) == COMPONENT_REF) { tree aggr = TREE_OPERAND (member, 0); + if (TREE_CODE (aggr) == VAR_DECL) + /* Initializing a local variable, don't add anything. */ + return true; if (TREE_CODE (aggr) != COMPONENT_REF) /* Normal member initialization. */ member = TREE_OPERAND (member, 1); diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C new file mode 100644 index 00000000000..7e05481a0ed --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C @@ -0,0 +1,10 @@ +// PR c++/79461 +// { dg-options -std=c++1z } + +struct S { + constexpr S(int i) { + auto f = [i]{}; + } +}; +int main() {} + -- 2.30.2