From 4fdda3ceb39dfe570b5583780628ae0301642b76 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 13 Jun 2018 20:02:42 -0400 Subject: [PATCH] PR c++/86099 - ICE with trivial copy and non-trivial default ctor. * constexpr.c (instantiate_cx_fn_r): Don't synthesize trivial constructors. From-SVN: r261576 --- gcc/cp/ChangeLog | 4 ++ gcc/cp/constexpr.c | 1 + gcc/testsuite/g++.dg/cpp0x/nsdmi-template18.C | 43 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/nsdmi-template18.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index abdccbc12cf..245b6364e2b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2018-06-13 Jason Merrill + PR c++/86099 - ICE with trivial copy and non-trivial default ctor. + * constexpr.c (instantiate_cx_fn_r): Don't synthesize trivial + constructors. + PR c++/86094 - wrong code with defaulted move ctor. * class.c (classtype_has_non_deleted_move_ctor): New. * tree.c (maybe_warn_parm_abi, type_has_nontrivial_copy_init): diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 97a338535db..93de6162c04 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -4841,6 +4841,7 @@ instantiate_cx_fn_r (tree *tp, int *walk_subtrees, void */*data*/) if (TREE_CODE (*tp) == FUNCTION_DECL && DECL_DECLARED_CONSTEXPR_P (*tp) && !DECL_INITIAL (*tp) + && !trivial_fn_p (*tp) && DECL_TEMPLOID_INSTANTIATION (*tp)) { ++function_depth; diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template18.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template18.C new file mode 100644 index 00000000000..e3520bc6b44 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template18.C @@ -0,0 +1,43 @@ +// PR c++/86099 +// { dg-do compile { target c++11 } } + +template struct e { static constexpr int c = a; }; +template using d = e; +template struct aa; +template struct j; +template struct j : aa::h {}; +template struct n : d {}; +template l m(int); +template auto ab() -> decltype(m(0)); +template struct p; +template struct p : e()))> {}; +template struct r; +class s; +template +struct ac : j, p, q...>> {}; +template struct ae : ac {}; +template struct aa { typedef ad h; }; +template struct w : j>, d> {}; +template struct r { + t f; + int af; + r(r &&) = default; +}; +template ::c, k>::h> void v(k *); +template ah aj(ag x, ah, ai) { v(x); return 0; } +template struct y { typedef int ak; }; +template class z { +public: + template void al(); +}; +template template void z::al() { + r *u; + typename y::ak a = aj(u, a, int()); +} +class s { + char *an = nullptr; +}; +void ao() { + z b; + b.al(); +} -- 2.30.2