diff mbox

[C++] PR 55323

Message ID 50A3C930.3050702@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Nov. 14, 2012, 4:39 p.m. UTC
Hi,

in this ICE on illegal what happens is the following: 
finish_mem_initializers calls check_for_bare_parameter_packs which 
errors out with "parameter packs not expanded with ‘...’" and returns 
true, thus the former does TREE_VALUE (mem) = error_mark_node. 
Eventually, emit_mem_initializers calls expand_aggr_init_1 with this 
error_mark_node as 'arguments' which hits the gcc_assert for init != 
error_mark_node.

A safe fix, which passes testing on x86_64-linux, seems just skipping 
the error_mark_node. I also considered simply returning, but that would 
certainly change the current behavior in terms of warnings produced for 
other bases when arguments == NULL_TREE.

Thanks,
Paolo.

/////////////////////
/cp
2012-11-14  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/55323
	* init.c (emit_mem_initializers): Skip arguments == error_mark_node.

/testsuite
2012-11-14  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/55323
	* g++.dg/cpp0x/vt-55323.C: New.

Comments

Jakub Jelinek Nov. 14, 2012, 4:49 p.m. UTC | #1
On Wed, Nov 14, 2012 at 05:39:12PM +0100, Paolo Carlini wrote:
> +      /* We will already have issued an error message.  */

The wording looks unclear.  Either we have issued already an error message,
or we will issue it.

	Jakub
Paolo Carlini Nov. 14, 2012, 4:52 p.m. UTC | #2
On 11/14/2012 05:49 PM, Jakub Jelinek wrote:
> On Wed, Nov 14, 2012 at 05:39:12PM +0100, Paolo Carlini wrote:
>> +      /* We will already have issued an error message.  */
> The wording looks unclear.  Either we have issued already an error message,
> or we will issue it.
You are right ;) Consider it amended to: "We already have issued an 
error message.".

Paolo.
Jason Merrill Nov. 14, 2012, 8:07 p.m. UTC | #3
OK.

Jason
diff mbox

Patch

Index: cp/init.c
===================================================================
--- cp/init.c	(revision 193495)
+++ cp/init.c	(working copy)
@@ -1047,12 +1047,17 @@  emit_mem_initializers (tree mem_inits)
   in_base_initializer = 1;
 
   /* Initialize base classes.  */
-  while (mem_inits
-	 && TREE_CODE (TREE_PURPOSE (mem_inits)) != FIELD_DECL)
+  for (; (mem_inits
+	  && TREE_CODE (TREE_PURPOSE (mem_inits)) != FIELD_DECL);
+       mem_inits = TREE_CHAIN (mem_inits))
     {
       tree subobject = TREE_PURPOSE (mem_inits);
       tree arguments = TREE_VALUE (mem_inits);
 
+      /* We will already have issued an error message.  */
+      if (arguments == error_mark_node)
+	continue;
+
       if (arguments == NULL_TREE)
 	{
 	  /* If these initializations are taking place in a copy constructor,
@@ -1085,8 +1090,6 @@  emit_mem_initializers (tree mem_inits)
                               tf_warning_or_error);
 	  expand_cleanup_for_base (subobject, NULL_TREE);
 	}
-
-      mem_inits = TREE_CHAIN (mem_inits);
     }
   in_base_initializer = 0;
 
Index: testsuite/g++.dg/cpp0x/vt-55323.C
===================================================================
--- testsuite/g++.dg/cpp0x/vt-55323.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/vt-55323.C	(working copy)
@@ -0,0 +1,12 @@ 
+// { dg-options "-std=c++11" }
+
+struct foo {
+  foo(int a, float b);
+};
+
+struct bar : foo {
+  template<typename... Args>
+  bar(Args&&... args) : foo(2, args){} // { dg-error "parameter packs" }
+};
+
+bar b(2,1.);