This patch fixes an ICE with inherited default ctor and a local decl. In such a case we don't have any conv args (just the object expression, handled differently). Thus 'num_convs-1' is -1 and we seg fault at:
 cand->convs[cand->num_convs-1]->ellipsis_p
do just check it's non-zero first.

committed to trunk

nathan
--
Nathan Sidwell
2017-01-18  Nathan Sidwell  <nat...@acm.org>

	PR c++/78488
	* call.c (build_over_call): When checking ellipsis conversions for
	an inherited ctor, make sure there is at least one conversion.

	* g++.dg/cpp1z/inh-ctor37.C: New.

Index: cp/call.c
===================================================================
--- cp/call.c	(revision 244586)
+++ cp/call.c	(working copy)
@@ -7899,6 +7899,7 @@ build_over_call (struct z_candidate *can
 	 could handle this by open-coding the inherited constructor rather than
 	 defining it, but let's not bother now.  */
       if (!cp_unevaluated_operand
+	  && cand->num_convs
 	  && cand->convs[cand->num_convs-1]->ellipsis_p)
 	{
 	  if (complain & tf_error)
Index: testsuite/g++.dg/cpp1z/inh-ctor37.C
===================================================================
--- testsuite/g++.dg/cpp1z/inh-ctor37.C	(revision 0)
+++ testsuite/g++.dg/cpp1z/inh-ctor37.C	(working copy)
@@ -0,0 +1,13 @@
+// { dg-do compile { target c++11 } }
+// PR 78488, seg fault with inherited ctor
+
+struct Foo { Foo() {} };
+
+struct Bar : Foo {
+  using Foo::Foo;
+  Bar(void*);
+};
+
+int main() {
+ Bar f;
+}

Reply via email to