Bug 34056 - [4.3 regression] ICE with parameter pack and pointer
Summary: [4.3 regression] ICE with parameter pack and pointer
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Jakub Jelinek
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2007-11-10 19:57 UTC by Volker Reichelt
Modified: 2007-11-13 18:28 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-11-13 13:43:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2007-11-10 19:57:21 UTC
The following invalid code snippet triggers an ICE on mainline:

=====================================================================
template<typename... T> struct A
{
  void foo(T*) { ++p; }
  T* p;
};
=====================================================================

bug.cc:3: error: parameter packs not expanded with `...':
bug.cc:3: note:         'T'
bug.cc: In member function 'void A<T>::foo(<type error>)':
bug.cc:3: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in build_unary_op, at cp/typeck.c:4296
Please submit a full bug report, [etc.]

The testcase didn't crash before 2007-11-03, so it's probably fallout from
http://gcc.gnu.org/ml/gcc-cvs/2007-11/msg00120.html
Comment 1 Jakub Jelinek 2007-11-13 12:12:10 UTC
The set_packs_to_error stuff is very problematic in this case, because
trees are shared and the C++ FE certainly doesn't expect error_mark_nodes
to appear at random places.
In this case T* type is shared (as the pointer to T has been cached).
check_for_bare_parameter_packs should have errored about this twice, but will
do only once because of the sharing and in the second case just won't fail,
so doesn't let the caller to deal with the errorneous type.
Comment 2 Jakub Jelinek 2007-11-13 13:43:49 UTC
Testing a fix.
Comment 3 Jakub Jelinek 2007-11-13 18:27:47 UTC
Subject: Bug 34056

Author: jakub
Date: Tue Nov 13 18:27:09 2007
New Revision: 130152

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130152
Log:
	PR c++/34054
	PR c++/34056
	PR c++/34057
	PR c++/34058
	PR c++/34060
	* pt.c (find_parameter_packs_r): If ppd->set_packs_to_error,
	set to error_mark_node the outermost POINTER_TYPE to the pack if
	it is seen in a POINTER_TYPE.
	(push_template_decl_real): If check_for_bare_parameter_packs
	fails for function return type, set the return type to
	integer_type_node.  If check_for_bare_parameter_packs failed
	for non-function, return error_mark_node.

	* g++.dg/parse/crash36.C: Add another dg-error.
	* g++.dg/cpp0x/pr34054.C: New test.
	* g++.dg/cpp0x/pr34056.C: New test.
	* g++.dg/cpp0x/pr34057.C: New test.
	* g++.dg/cpp0x/pr34058.C: New test.
	* g++.dg/cpp0x/pr34060.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr34054.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr34056.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr34057.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr34058.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr34060.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/parse/crash36.C

Comment 4 Jakub Jelinek 2007-11-13 18:28:36 UTC
Fixed.