Bug 17826 - [3.4/4.0 Regression] ICE in cp_tree_equal
Summary: [3.4/4.0 Regression] ICE in cp_tree_equal
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 critical
Target Milestone: 3.4.3
Assignee: Mark Mitchell
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2004-10-04 07:21 UTC by Jakub Jelinek
Modified: 2004-10-10 05:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.2.2 2.95.3 3.3.5
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-10-04 11:03:19


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2004-10-04 07:21:31 UTC
struct A
{
  template <bool B> struct C { static const bool c = false; };
  template <class T> static T &foo ();
};

struct D
{
  template <class T, bool B> struct E { };
};

template <class T, bool B>
class E
{
public:
  E (const T &t) : e (t) { }
private:
  T e;
};

template <class T>
void bar (const T &t)
{
  typedef typename D::E <T, A::C <(sizeof (foo (A::foo <T*> ()))
                                   == sizeof (A::C <true>))>::c> F;
  new E <T, !A::C <(sizeof (foo (A::foo <T*> ()))
                    == sizeof (A::C <true>))>::c> (t);
}

works in G++ 3.3.x, ICEs in cp_tree_equal in 3.4.2 and on HEAD, with -O0 or -O2,
on both {i386,x86_64}-redhat-linux.
Comment 1 Giovanni Bajo 2004-10-04 11:03:19 UTC
Confirmed. Looks like cp_tree_equal need to be taught about BASELINKs.
Comment 2 Andrew Pinski 2004-10-04 11:43:33 UTC
Looks like the new parser caused it:
: Search converges between 2002-12-14-trunk (#159) and 2002-12-29-trunk (#160).
Comment 3 Volker Reichelt 2004-10-07 01:25:20 UTC
Here's something shorter:

=====================================================
struct A
{
    template<typename> static int foo();
};

template<int> struct B {};

template<typename T> void bar()
{
    B<sizeof A::foo<T>()> b1;
    B<sizeof A::foo<T>()> b2;
}
=====================================================
Comment 4 CVS Commits 2004-10-10 05:03:01 UTC
Subject: Bug 17826

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-10-10 05:02:54

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog error.c init.c parser.c tree.c 
Added files:
	gcc/testsuite/g++.dg/init: new11.C 
	gcc/testsuite/g++.dg/parse: error19.C error20.C 
	gcc/testsuite/g++.dg/template: crash24.C 

Log message:
	PR c++/17867
	* error.c (dump_expr): Correct handling of AGGR_INIT_EXPRs using a
	constructor.
	
	PR c++/17670
	* init.c (build_new): Correct comments.
	* parser.c (cp_parser_new_expression): Use NULL_TREE for nelts in
	the non-array case.
	
	PR c++/17821
	* parser.c (cp_parser_postfix_dot_deref_expression): If the
	pseduo-destructor-name production does not work, fall back to the
	ordinary production.
	
	PR c++/17826
	* tree.c (cp_tree_equal): Handle a BASELINK.
	
	PR c++/17687
	* g++.dg/parse/error19.C: New test.
	
	PR c++/17670
	* g++.dg/init/new11.C: New test.
	
	PR c++/17821
	* g++.dg/parse/error20.C: New test.
	
	PR c++/17826
	* g++.dg/template/crash24.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4426&r2=1.4427
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4416&r2=1.4417
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/error.c.diff?cvsroot=gcc&r1=1.266&r2=1.267
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.398&r2=1.399
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.261&r2=1.262
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.413&r2=1.414
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/new11.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error19.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error20.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash24.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 5 CVS Commits 2004-10-10 05:28:38 UTC
Subject: Bug 17826

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-10-10 05:28:32

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog parser.c tree.c 
Added files:
	gcc/testsuite/g++.dg/parse: error20.C 
	gcc/testsuite/g++.dg/template: crash24.C 

Log message:
	PR c++/17867
	* error.c (dump_expr): Correct handling of AGGR_INIT_EXPRs using a
	constructor.
	
	PR c++/17670
	* init.c (build_new): Correct comments.
	* parser.c (cp_parser_new_expression): Use NULL_TREE for nelts in
	the non-array case.
	
	PR c++/17821
	* parser.c (cp_parser_postfix_dot_deref_expression): If the
	pseduo-destructor-name production does not work, fall back to the
	ordinary production.
	
	PR c++/17826
	* tree.c (cp_tree_equal): Handle a BASELINK.
	
	PR c++/17687
	* g++.dg/parse/error19.C: New test.
	
	PR c++/17670
	* g++.dg/init/new11.C: New test.
	
	PR c++/17821
	* g++.dg/parse/error20.C: New test.
	
	PR c++/17826
	* g++.dg/template/crash24.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.281&r2=1.3389.2.282
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.165&r2=1.3892.2.166
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.42&r2=1.157.2.43
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.360.4.9&r2=1.360.4.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error20.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash24.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 6 Mark Mitchell 2004-10-10 05:36:17 UTC
Fixed in GCC 3.4.3