Bug 7939 - [3.3 regression] ICE on function template specialization
Summary: [3.3 regression] ICE on function template specialization
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3
: P3 minor
Target Milestone: 3.3.2
Assignee: Kriang Lerdsuwanakij
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2002-09-16 14:56 UTC by kparz
Modified: 2003-10-29 01:22 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-08-02 03:52:53


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kparz 2002-09-16 14:56:00 UTC
Attempt to create a partial specialization of a function template (problem 1)
with a type `void' used as a function argument type (problem 2) causes an
internal compiler error.

Release:
3.3 20020916 (experimental)

Environment:
System: FreeBSD arcturus.student.iastate.edu 4.6-STABLE FreeBSD 4.6-STABLE #15: Sat Aug 24 23:25:48 CDT 2002 kparz@arcturus.student.iastate.edu:/usr/obj/usr/src/sys/ARCTURUS i386



host: i386-unknown-freebsd4.6
build: i386-unknown-freebsd4.6
target: i386-unknown-freebsd4.6
configured with: ../gcc/configure --prefix=/u/gcc-20020916 --enable-languages=c,c++,f77

How-To-Repeat:
# 1 "gcc-ice1.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "gcc-ice1.cc"
template <class T, class U> void foo(T, U) {}
template <class T> void foo<T,void>(T, void) {}
Comment 1 Kriang Lerdsuwanakij 2002-09-28 07:22:40 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.
Comment 2 Giovanni Bajo 2003-05-05 02:46:22 UTC
From: "Giovanni Bajo" <giovannibajo@libero.it>
To: <gcc-gnats@gcc.gnu.org>,
	<kparz@iastate.edu>,
	<gcc-bugs@gcc.gnu.org>,
	<nobody@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>
Cc:  
Subject: Re: c++/7939: [3.3/3.4 regression] [2003-05-03] ICE on function template specialization
Date: Mon, 5 May 2003 02:46:22 +0200

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7939
 
 This is a regression from 2.95. Currently, we get the following on mainline
 and 3.3:
 
 pr7939.cpp:2: error: `<anonymous>' has incomplete type
 pr7939.cpp:2: error: invalid use of `void'
 pr7939.cpp:2: error: partial specialization `foo<T, void>' of function
 template
 pr7939.cpp:2: internal compiler error: in comptypes, at cp/typeck.c:913
 Please submit a full bug report,
 
 while we used to get this on 2.95:
 
 pr7939.cpp:2: template-id `foo<T, void>' in declaration of primary template
 
 So, there is actually an improvement on the error message (the parser is
 able to understand that the code is trying to define a partial
 specialization of a function template, which is indeed a great diagnostic),
 but then it ICEs during error recovery. I think the error message could also
 be a little epurated (removing those other lines if possible, especially the
 one with <anonymous> which is really cryptic), and maybe specifying
 explicitally that "partial specialization of function template is not
 allowed by ISO C++".
 
 Giovanni Bajo
Comment 3 Andrew Pinski 2003-06-23 16:23:39 UTC
Moving target back to 3.3.1.
Comment 4 Andrew Pinski 2003-06-29 16:28:38 UTC
It also ICEs in 3.0.4.
Comment 5 Mark Mitchell 2003-07-11 22:18:27 UTC
Postponed until GCC 3.3.2.
Comment 6 Steven Bosscher 2003-07-14 11:02:47 UTC
FWIW it was broken in "2.97 20001230 (experimental)" already so it's really old.
: Test is the same (fail) at both endpoints (2000-12-31-trunk,
: 2003-07-13-trunk)
Comment 7 Dara Hazeghi 2003-08-24 17:21:46 UTC
Still there on mainline (20030817). Not target specific, so removing target info.
Comment 8 Mark Mitchell 2003-09-05 06:18:18 UTC
Postponing ICE-after-valid until GCC 3.4.
Comment 9 CVS Commits 2003-09-16 15:27:56 UTC
Subject: Bug 7939

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	lerdsuwa@gcc.gnu.org	2003-09-16 15:27:51

Modified files:
	gcc/cp         : ChangeLog typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: crash11.C 

Log message:
	PR c++/7939
	* typeck.c (comptypes): Don't ICE when its first argument is
	error_mark_node.
	(compparms): Reverse the arguments of same_type_p.
	
	* g++.dg/template/crash11.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3681&r2=1.3682
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.503&r2=1.504
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3058&r2=1.3059
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash11.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 10 Kriang Lerdsuwanakij 2003-09-16 15:37:06 UTC
Fixed on mainline (future GCC 3.4) by patch

  http://gcc.gnu.org/ml/gcc-patches/2003-09/msg01033.html

I am keeping this open to see if it can get into 3.3.2 as well.
Comment 11 Kriang Lerdsuwanakij 2003-09-25 12:24:40 UTC
Patch for 3.3 branch submitted:

  http://gcc.gnu.org/ml/gcc-patches/2003-09/msg01681.html
Comment 12 andreasmeier80 2003-10-04 09:06:50 UTC
Patch for 3.3 branch submitted:

  http://gcc.gnu.org/ml/gcc-patches/2003-09/msg01681.html
Comment 13 Mark Mitchell 2003-10-05 18:32:51 UTC
Subject: Re:  [3.3 regression] ICE on function template
	specialization

On Sat, 2003-10-04 at 02:06, andreas dot meier_ at gmx dot de wrote:
> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7939

This patch is OK.

Comment 14 CVS Commits 2003-10-16 02:31:05 UTC
Subject: Bug 7939

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	mmitchel@gcc.gnu.org	2003-10-16 02:31:00

Modified files:
	gcc/cp         : ChangeLog typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: crash11.C 

Log message:
	PR c++/7939
	* typeck.c (comptypes): Don't ICE when its first argument is
	error_mark_node.
	(compparms): Reverse the arguments of same_type_p.
	
	PR c++/7939
	* g++.dg/template/crash11.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.215&r2=1.3076.2.216
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.436.2.18&r2=1.436.2.19
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.306&r2=1.2261.2.307
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash11.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.12.1

Comment 15 Mark Mitchell 2003-10-16 02:35:29 UTC
Fixed in GCC 3.3.2.