Bug 10555 - ICE on undefined template argument
Summary: ICE on undefined template argument
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: 3.3.3
Assignee: Kriang Lerdsuwanakij
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2003-04-29 20:06 UTC by Volker Reichelt
Modified: 2004-01-25 16:08 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2003-04-29 20:06:00 UTC
Consider the following code snippet:

-------------------------------snip here------------------------
template <typename> struct A
{
    template <typename> struct B;
};

template <typename T> struct C
{
    typedef typename A<T>::template B<U> X; // U is undefined
};

C<void> c;
-------------------------------snip here------------------------

PR8582D.cc:8: error: `U' has not been declared
PR8582D.cc: In instantiation of `C<void>':
PR8582D.cc:11:   instantiated from here
PR8582D.cc:8: error: template argument 1 is invalid
PR8582D.cc:8: internal compiler error: tree check: expected tree_vec, have 
   error_mark in check_instantiated_args, at cp/pt.c:8403
Please submit a full bug report, [etc.]

This error recovery problem affects mainline, 3.3 branch and the 3.2 branch
(at least if configured with --enable-checking).
So it's a regression from 3.0.x.

Release:
2.95.x - 3.4-20030402

Environment:
i686-pc-linux-gnu
Comment 1 Wolfgang Bangerth 2003-04-29 21:47:27 UTC
State-Changed-From-To: open->feedback
State-Changed-Why: Confirmed, but I don't think it's a regression: in 3.0 I
    get "confused by earlier messages" and in 2.95 an ICE:
    
    g/x> /home/bangerth/bin/gcc-3.0.4/bin/c++ -c x.cc
    x.cc: In instantiation of `C<void>':
    x.cc:11:   instantiated from here
    x.cc:8: type/value mismatch at argument 1 in template parameter list for
       `template<{template default argument error}> template<{template default
       argument error}> struct A<<anonymous template type parameter> >::B'
    x.cc:8:   expected a type, got `U'
    x.cc:8: confused by earlier errors, bailing out
    g/x>
    g/x>
    g/x> c++ -c x.cc
    x.cc: In instantiation of `A<void>':
    x.cc:8:   instantiated from `C<void>'
    x.cc:11:   instantiated from here
    x.cc:8: Internal compiler error.
    x.cc:8: Please submit a full bug report.
    x.cc:8: See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
    
    What do you think?
    
    W.
Comment 2 Volker Reichelt 2003-04-30 13:12:02 UTC
State-Changed-From-To: feedback->analyzed
State-Changed-Why: Of course it's not a regression.
    I just read didn't read the error messages of gcc 3.0.x
    careful enough, sorry.
Comment 3 Kriang Lerdsuwanakij 2003-05-07 15:02:45 UTC
Responsible-Changed-From-To: unassigned->lerdsuwa
Responsible-Changed-Why: Fixing.
Comment 4 Kriang Lerdsuwanakij 2003-05-09 15:09:14 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in the main trunk.
Comment 5 Kriang Lerdsuwanakij 2003-05-09 15:10:29 UTC
From: lerdsuwa@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/10555
Date: 9 May 2003 15:10:29 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	lerdsuwa@gcc.gnu.org	2003-05-09 15:10:29
 
 Modified files:
 	gcc/cp         : ChangeLog pt.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/template: memclass1.C 
 
 Log message:
 	PR c++/10555, c++/10576
 	* pt.c (lookup_template_class): Handle class template with
 	multiple levels of parameters when one of the levels contain
 	errors.
 	
 	* g++.dg/template/memclass1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3370&r2=1.3371
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.688&r2=1.689
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2667&r2=1.2668
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memclass1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Comment 6 GCC Commits 2004-01-25 15:08:25 UTC
Subject: Bug 10555

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	lerdsuwa@gcc.gnu.org	2004-01-25 15:08:20

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: nontype4.C nontype5.C memclass1.C 

Log message:
	PR c++/13797
	* pt.c (instantiate_class_template): Add an error_mark_node
	check.
	(tsubst_decl) <TEMPLATE_DECL case>: Likewise.
	
	Backport from mainline
	2003-05-09  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
	
	PR c++/10555, c++/10576
	* pt.c (lookup_template_class): Handle class template with
	multiple levels of parameters when one of the levels contain
	errors.
	
	* g++.dg/template/nontype4.C: New test.
	* g++.dg/template/nontype5.C: Likewise.
	* g++.dg/template/memclass1.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.242&r2=1.3076.2.243
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.635.2.41&r2=1.635.2.42
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.352&r2=1.2261.2.353
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/nontype4.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/nontype5.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memclass1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.2.16.1