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.carl...@oracle.com>
PR c++/55323
* init.c (emit_mem_initializers): Skip arguments == error_mark_node.
/testsuite
2012-11-14 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/55323
* g++.dg/cpp0x/vt-55323.C: New.
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.);