This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/82152, ICE with class deduction and inherited ctor


Building a deduction guide for a constructor inherited from a
non-dependent base got confused because it has no template parameters.

Since there's no way an inherited constructor could be useful for
class template argument deduction, we can just skip them.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit ea6f7a867106c563c0eb0c419d5f167d05426a9d
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 5 12:23:14 2018 -0400

            PR c++/82152 - ICE with class deduction and inherited ctor.
    
            * pt.c (do_class_deduction): Ignore inherited ctors.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index dc74635876e..dc2310aefa8 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -26217,6 +26217,10 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags,
   // FIXME cache artificial deduction guides
   for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (type)); iter; ++iter)
     {
+      /* Skip inherited constructors.  */
+      if (iter.using_p ())
+	continue;
+
       tree guide = build_deduction_guide (*iter, outer_args, complain);
       if (guide == error_mark_node)
 	return error_mark_node;
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction54.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction54.C
new file mode 100644
index 00000000000..e51398bbbb0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction54.C
@@ -0,0 +1,15 @@
+// PR c++/82152
+// { dg-additional-options -std=c++17 }
+
+struct Base {};
+
+template<typename T>
+struct Derived : public Base {
+  using Base::Base;
+};
+
+Derived() -> Derived< void >;
+
+int main() {
+  Derived x;
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]