From: Jason Merrill Date: Fri, 19 Jun 2015 18:15:30 +0000 (-0400) Subject: re PR c++/65973 (segmentation fault when compiling C++14 code) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=30ac6e80ba51480a0066329338b3ea5dbf423c26;p=gcc.git re PR c++/65973 (segmentation fault when compiling C++14 code) PR c++/65973 * constexpr.c (build_constexpr_constructor_member_initializers): Handle an empty STATEMENT_LIST. From-SVN: r224677 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4f2d4a6e27b..2f5e0fa8c12 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2015-06-19 Jason Merrill + PR c++/65973 + * constexpr.c (build_constexpr_constructor_member_initializers): + Handle an empty STATEMENT_LIST. + PR c++/65843 * pt.c (tsubst_copy_and_build): Register a capture proxy in local_specializations. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 56885883d72..f6e2bc8508c 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -537,16 +537,16 @@ build_constexpr_constructor_member_initializers (tree type, tree body) body = TREE_OPERAND (body, 0); if (TREE_CODE (body) == STATEMENT_LIST) { - tree_stmt_iterator i = tsi_start (body); - while (true) + for (tree_stmt_iterator i = tsi_start (body); + !tsi_end_p (i); tsi_next (&i)) { body = tsi_stmt (i); if (TREE_CODE (body) == BIND_EXPR) break; - tsi_next (&i); } } - body = BIND_EXPR_BODY (body); + if (TREE_CODE (body) == BIND_EXPR) + body = BIND_EXPR_BODY (body); if (TREE_CODE (body) == CLEANUP_POINT_EXPR) { body = TREE_OPERAND (body, 0); diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-empty1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-empty1.C new file mode 100644 index 00000000000..5be44eabdd0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-empty1.C @@ -0,0 +1,6 @@ +// PR c++/65973 +// { dg-do compile { target c++14 } } + +class foo { + constexpr foo() noexcept { __func__; }; +};