[gcc(refs/users/marxin/heads/marxin-gcc-benchmark-branch)] PR c++/92594 - ICE with inherited trivial default ctor.

Martin Liska marxin@gcc.gnu.org
Mon Mar 30 10:04:50 GMT 2020


https://gcc.gnu.org/g:8982b5535c2762f566fd15e5862acf4702a78690

commit 8982b5535c2762f566fd15e5862acf4702a78690
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Jan 14 01:00:48 2020 -0500

            PR c++/92594 - ICE with inherited trivial default ctor.
    
    Here we were getting confused about whether or not pod_tuple has a trivial
    default constructor.  bar inherits the trivial e default constructor; the
    effect of calling that inherited constructor is equivalent to calling a
    defaulted default constructor in bar, so let's treat it as such.
    
            * method.c (trivial_fn_p): Treat an inherited default constructor
            like a normal default constructor.

Diff:
---
 gcc/cp/ChangeLog                        |  4 ++++
 gcc/cp/method.c                         |  7 ++++++-
 gcc/testsuite/g++.dg/cpp0x/inh-ctor34.C | 13 +++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f7e5e74d281..3fd35b437b4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
 2020-01-14  Jason Merrill  <jason@redhat.com>
 
+	PR c++/92594 - ICE with inherited trivial default ctor.
+	* method.c (trivial_fn_p): Treat an inherited default constructor
+	like a normal default constructor.
+
 	PR c++/92009 - ICE with punning of typeid.
 	* rtti.c (get_tinfo_desc): Call xref_basetypes.
 	* constexpr.c (cxx_fold_indirect_ref): Don't strip
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index fef19e18196..e20a88febdc 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -458,7 +458,12 @@ trivial_fn_p (tree fn)
   /* If fn is a clone, get the primary variant.  */
   if (tree prim = DECL_CLONED_FUNCTION (fn))
     fn = prim;
-  return type_has_trivial_fn (DECL_CONTEXT (fn), special_function_p (fn));
+  special_function_kind sfk = special_function_p (fn);
+  /* An inherited default constructor is equivalent to a non-inherited default
+     constructor, so let it be trivial.  */
+  if (sfk == sfk_inheriting_constructor && default_ctor_p (fn))
+    sfk = sfk_constructor;
+  return type_has_trivial_fn (DECL_CONTEXT (fn), sfk);
 }
 
 /* PARM is a PARM_DECL for a function which we want to forward to another
diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor34.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor34.C
new file mode 100644
index 00000000000..9afc0e9e536
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/inh-ctor34.C
@@ -0,0 +1,13 @@
+// PR c++/92594
+// { dg-do compile { target c++11 } }
+
+template <typename _Head> struct tuple {
+  tuple() : _M_head_impl() {}
+  _Head _M_head_impl;
+};
+template <typename type0> struct pod_tuple { type0 _head; };
+struct e {};
+struct bar : e {
+  using e::e;
+};
+int main() { tuple<pod_tuple<bar>> a; }


More information about the Gcc-cvs mailing list