Bug 32115

Summary: [4.3 regression] ICE with default argument in variadic template
Product: gcc Reporter: Volker Reichelt <reichelt>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: dgregor, fang, gcc-bugs
Priority: P4 Keywords: error-recovery, ice-on-invalid-code, monitored
Version: 4.3.0   
Target Milestone: 4.3.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Volker Reichelt 2007-05-27 23:00:48 UTC
The following invalid code snippet triggers an ICE on mainline:

====================================================
template<typename ...T, int = 0> struct A {};

A<int> a;
====================================================

bug.cc:1: error: parameter pack 'T' must be at the end of the template parameter list
bug.cc:3: internal compiler error: tree check: accessed elt 3 of tree_vec with 2 elts in coerce_template_parms, at cp/pt.c:5056
Please submit a full bug report, [etc.]
Comment 1 dgregor 2007-11-06 14:38:48 UTC
Subject: Bug 32115

Author: dgregor
Date: Tue Nov  6 14:37:56 2007
New Revision: 129928

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129928
Log:
2007-11-06  Douglas Gregor  <doug.gregor@gmail.com>

	PR c++/31439
	PR c++/32114
	PR c++/32115
	PR c++/32125
	PR c++/32126
	PR c++/32127
	PR c++/32128
	PR c++/32253
	PR c++/32566
	* typeck.c (check_return_expr): Pass address of retval to
	check_for_bare_parameter_packs.
	* class.c (build_base_field): Tolerate bases that have no layout
	due to errors.
	(end_of_base): Ditto.
	* tree.c (canonical_type_variant): Be careful with
	ERROR_MARK_NODE.
	* cp-tree.h (check_for_bare_parameter_packs): Now accepts a
	tree*.
	* pt.c (find_parameter_pack_data): Add set_packs_to_error field,
	which states whether parameter packs should be replaced with
	ERROR_MARK_NODE.
	(find_parameter_packs_r): Pass addresses to cp_walk_tree wherever
	possible. If set_packs_to_error is set true, replace the parameter
	pack with ERROR_MARK_NODE. Manage our own pointer sets.
	(uses_parameter_packs): Don't set parameter packs to
	ERROR_MARK_NODE.
	(check_for_bare_parameter_packs): Now takes a pointer to a tree,
	which may be modified (if it is a parameter pack). Instructs
	find_parameter_packs_r to replace parameter packs with
	ERROR_MARK_NODE (so that they won't cause errors later on).
	(process_template_parm): Pass pointer to
	check_for_bare_parameter_packs.
	(process_partial_specialization): Replace pack expansions before
	the end of the template argument list with ERROR_MARK_NODE.
	(push_template_decl_real): Pass pointer to
	check_for_bare_parameter_packs. Replace parameter packs not at the
	end of the template parameter list with ERROR_MARK_NODE.
	(convert_template_argument): Be more careful about using DECL_NAME
	on only declarations.
	(unify): Can't unify against ERROR_MARK_NODE.
	* semantics.c (finish_cond): Pass pointer to
	check_for_bare_parameter_packs.
	(finish_expr_stmt): Ditto.
	(finish_for_expr): Ditto.
	(finish_switch_cond): Pass pointer to
	check_for_bare_parameter_packs, and call it before we put the
	condition into the statement.
	(finish_mem_initializers): Pass pointer to
	check_for_bare_parameter_packs.
	(finish_member_declaration): Ditto.
	* parser.c (cp_parser_base_clause): Ditto.
	
2007-11-06  Douglas Gregor  <doug.gregor@gmail.com>

	* testsuite/g++.dg/parser/crash36.C: Tweak expected errors.
	* testsuite/g++.dg/cpp0x/pr31439.C: New.
	* testsuite/g++.dg/cpp0x/pr32114.C: New.
	* testsuite/g++.dg/cpp0x/pr32115.C: New.
	* testsuite/g++.dg/cpp0x/pr32125.C: New.
	* testsuite/g++.dg/cpp0x/pr32126.C: New.
	* testsuite/g++.dg/cpp0x/pr32127.C: New.
	* testsuite/g++.dg/cpp0x/pr32128.C: New.
	* testsuite/g++.dg/cpp0x/pr32253.C: New.
	* testsuite/g++.dg/cpp0x/pr32566.C: New.
	* testsuite/g++.dg/cpp0x/pr31445.C: Tweak expected errors.
	* testsuite/g++.dg/cpp0x/pr31438.C: Ditto.
	* testsuite/g++.dg/cpp0x/variadic81.C: Ditto.
	* testsuite/g++.dg/cpp0x/pr31432.C: Ditto.
	* testsuite/g++.dg/cpp0x/pr31442.C: Ditto.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr31439.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr32114.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr32115.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr32125.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr32126.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr32127.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr32128.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr32253.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr32566.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/cp/tree.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/pr31432.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr31438.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr31442.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr31445.C
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic81.C
    trunk/gcc/testsuite/g++.dg/parse/crash36.C

Comment 2 dgregor 2007-11-06 14:42:53 UTC
Fixed