aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-06-13 20:02:42 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-06-13 20:02:42 -0400
commit4fdda3ceb39dfe570b5583780628ae0301642b76 (patch)
treeea0c1a92e87036b9a00e85dac50eaf0db7639338 /gcc
parent5cef3733596c6424dee18d7e36bc41162628653b (diff)
downloadgcc-4fdda3ceb39dfe570b5583780628ae0301642b76.zip
gcc-4fdda3ceb39dfe570b5583780628ae0301642b76.tar.gz
gcc-4fdda3ceb39dfe570b5583780628ae0301642b76.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/constexpr.c1
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nsdmi-template18.C43
3 files changed, 48 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index abdccbc..245b636 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2018-06-13 Jason Merrill <jason@redhat.com>
+ 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 97a3385..93de616 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 0000000..e3520bc
--- /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 <int a> struct e { static constexpr int c = a; };
+template <bool a> using d = e<a>;
+template <bool, typename> struct aa;
+template <typename...> struct j;
+template <typename f, typename g> struct j<f, g> : aa<f::c, g>::h {};
+template <typename i> struct n : d<i::c> {};
+template <typename k, typename l = k> l m(int);
+template <typename k> auto ab() -> decltype(m<k>(0));
+template <typename...> struct p;
+template <typename k, typename o> struct p<k, o> : e<noexcept(k(ab<o>()))> {};
+template <typename> struct r;
+class s;
+template <typename, typename... q>
+struct ac : j<d<true>, p<r<s>, q...>> {};
+template <typename k> struct ae : ac<k, k> {};
+template <bool, typename ad> struct aa { typedef ad h; };
+template <typename k> struct w : j<n<ae<k>>, d<true>> {};
+template <typename t> struct r {
+ t f;
+ int af;
+ r(r &&) = default;
+};
+template <typename k, typename = typename aa<w<k>::c, k>::h> void v(k *);
+template <typename ag, typename ah, typename ai> ah aj(ag x, ah, ai) { v(x); return 0; }
+template <typename> struct y { typedef int ak; };
+template <typename, typename = int> class z {
+public:
+ template <typename...> void al();
+};
+template <typename k, typename am> template <typename...> void z<k, am>::al() {
+ r<s> *u;
+ typename y<am>::ak a = aj(u, a, int());
+}
+class s {
+ char *an = nullptr;
+};
+void ao() {
+ z<int> b;
+ b.al();
+}