From 3d8dfcb4175dc4077e54e9cbf8e8db40881a9165 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 15 Apr 2016 15:47:19 -0400 Subject: [PATCH] re PR c++/70685 (ICE: Segmentation fault) PR c++/70685 * constexpr.c (get_fundef_copy): Handle null *slot. From-SVN: r235045 --- gcc/cp/ChangeLog | 3 + gcc/cp/constexpr.c | 2 +- gcc/testsuite/g++.dg/cpp1y/constexpr-hana1.C | 76 ++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-hana1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b159c9b4f1b..ad7a246f2bd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2016-04-15 Jason Merrill + PR c++/70685 + * constexpr.c (get_fundef_copy): Handle null *slot. + PR c++/70505 * pt.c (tsubst_baselink): Give the new TEMPLATE_ID_EXPR unknown_type_node, too. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index d9b9a2888f9..ae0c9739d8d 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -998,7 +998,7 @@ get_fundef_copy (tree fun) tree copy; tree *slot = fundef_copies_table->get (fun); - if (slot == NULL) + if (slot == NULL || *slot == NULL_TREE) { copy = build_tree_list (NULL, NULL); /* PURPOSE is body, VALUE is parms, TYPE is result. */ diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-hana1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-hana1.C new file mode 100644 index 00000000000..f8a9aa0578c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-hana1.C @@ -0,0 +1,76 @@ +// PR c++/70685 +// { dg-do compile { target c++14 } } + +namespace std { +template struct A { static constexpr _Tp value = __v; +}; +typedef A false_type; +template using conditional_t = _Iftrue; +namespace hana { +template struct is_default : false_type {}; +template struct tag_of; +struct deleted_implementation; +namespace detail { +namespace operators { +template struct adl {}; +} +} +template struct B; +template struct G : std::A {}; +template G integral_c; +template using int_ = G; +template int_ int_c; +template struct C; +template struct D { + template auto operator()(X... x) { + return C::apply(x...); + } +}; +template D make; +template struct unpack_impl; +struct Foldable { + using Tag = int; + static constexpr int value = is_default>::value; +}; +struct range_tag; +auto make_range = make; +template struct sum_impl; +template struct F; +template > F sum; +template +struct range : detail::operators::adl> {}; +template struct tag_of> { + using type = range_tag; +}; +template <> struct C { + template static auto apply(From, To) { + using T = int; + constexpr T from(From::value); + constexpr T to(To::value); + return range{}; + } +}; +template <> struct sum_impl { + template static constexpr I sum_helper(I m, I n) { + if (m == n) + return 0; + return sum_helper(0, 0); + } + template static auto apply(range) { + integral_c; + } +}; +template struct F { + template auto operator()(Xs xs) { + using S = typename tag_of::type; + using Sum = + conditional_t, deleted_implementation>; + Sum::apply(xs); + } +}; +} +auto __hana_tmp_22 = + (hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<-2>)), + hana::sum<>(hana::make_range(hana::int_c<3>, hana::int_c<7>)), + hana::int_c<6>); +} -- 2.30.2