From: Marek Polacek Date: Thu, 26 Feb 2015 15:03:23 +0000 (+0000) Subject: re PR c++/65202 (ICE segfault with constexpr/noexcept) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=75e0295b00aeeddbd4efb2e55ef3ed946f886a86;p=gcc.git re PR c++/65202 (ICE segfault with constexpr/noexcept) PR c++/65202 * constexpr.c (cxx_eval_constant_expression): Don't evaluate a RETURN_EXPR if its operand is null. * g++.dg/cpp1y/pr65202.C: New test. From-SVN: r221015 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ebe84c6dc69..7fcbcb93df0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-02-26 Marek Polacek + + PR c++/65202 + * constexpr.c (cxx_eval_constant_expression): Don't evaluate + a RETURN_EXPR if its operand is null. + 2015-02-25 Jason Merrill PR c++/65209 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 32a23ff7380..f7e8ce949f3 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -3113,9 +3113,10 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, break; case RETURN_EXPR: - r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0), - lval, - non_constant_p, overflow_p); + if (TREE_OPERAND (t, 0) != NULL_TREE) + r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0), + lval, + non_constant_p, overflow_p); *jump_target = t; break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4f9ce8e08b6..41c0685db70 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-26 Marek Polacek + + PR c++/65202 + * g++.dg/cpp1y/pr65202.C: New test. + 2015-02-26 Tom de Vries * g++.dg/gcov/gcov-14.C: Add cleanup of iostream.gcov, ostream.gcov and diff --git a/gcc/testsuite/g++.dg/cpp1y/pr65202.C b/gcc/testsuite/g++.dg/cpp1y/pr65202.C new file mode 100644 index 00000000000..602b264b302 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr65202.C @@ -0,0 +1,26 @@ +// // PR c++/65202 +// { dg-do compile { target c++14 } } + +template struct is_move_constructible; +template struct is_move_assignable; +template using enable_if_t = int; +namespace adl { +template < + typename L, typename R, + enable_if_t() && is_move_assignable(), int>...> +constexpr auto adl_swap(L &l, R &r) -> decltype(swap(l, r)) { + return; +} +template +auto swap(L &l, R &r) noexcept(noexcept(adl::adl_swap(l, r))) + -> decltype(adl::adl_swap(l, r)); +namespace ns { +template struct foo {}; +template void swap(foo &, foo &); +struct bar; + +int main() +{ + foo f; + adl::swap(f, f) +} // { dg-error "" }