Bug 17068 - [3.4/4.0 regression] ICE: tree check: expected class 'd', have 'x' (identifier_node) in dependent_template_p, at cp/pt.c:12043
Summary: [3.4/4.0 regression] ICE: tree check: expected class 'd', have 'x' (identifie...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 critical
Target Milestone: 3.4.2
Assignee: Mark Mitchell
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2004-08-17 19:28 UTC by Václav Haisman
Modified: 2004-10-30 21:11 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.4
Known to fail: 3.4.0 3.4.1 4.0.0
Last reconfirmed: 2004-08-17 19:55:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Václav Haisman 2004-08-17 19:28:48 UTC
Compiling the following testcase GCC ICEs with the error bellow.
The test case is derived from one configure test of libsigc++2.x.

struct Thing
{
  template <class T>
  void operator()(T a, T b)
  { }
};

template<class T2>
struct OtherThing
{
  void do_something()
  {
    Thing thing_;
    thing_.template operator()<T2>(1, 2);
  }
};

wilx@logout:::~/tmp> g++ -c libsigc++-test.cxx
libsigc++-test.cxx: In member function `void OtherThing<T2>::do_something()':
libsigc++-test.cxx:14: internal compiler error: tree check: expected class 'd',
have 'x' (identifier_node) in dependent_template_p, at cp/pt.c:12043
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Volker Reichelt 2004-08-17 19:55:10 UTC
Confirmed. Here's a reduced code snippet:

=============================================
struct A
{
    template<int> void operator()() {}
};

template<typename> void foo()
{
    A().template operator()<0>();
}
=============================================
Comment 2 Wolfgang Bangerth 2004-08-17 20:15:16 UTC
Well done, Volker: this intriguing anagramatic sequence in your testcase 
  ()<0>() 
clearly asks for an award for "art in testcases" :-) 
 
W. 
Comment 3 Andrew Pinski 2004-08-17 20:23:43 UTC
: Search converges between 2003-07-08-trunk (#288) and 2003-07-09-trunk (#289).

I almost think it was caused by:
2003-07-08  Mark Mitchell  <mark@codesourcery.com>

        * cp-tree.def (NON_DEPENDENT_EXPR): New node.
        * cp-tree.h (build_call_from_tree): Remove.
        (build_member_call): Likewise.
        ...., etc.
Comment 4 Volker Reichelt 2004-08-17 21:11:53 UTC
> ------- Additional Comments From bangerth at dealii dot org  2004-08-17 20:15
-------
> Well done, Volker: this intriguing anagramatic sequence in your testcase 
>   ()<0>() 
> clearly asks for an award for "art in testcases" :-) 

Well, I couldn't help it - I had to find a really symmetric testcase. :-)
And here it is (it's a modified version from PR 16971). You can read
it forwards and backwards (well, you have to revert the braces):

=============================================
namespace { ; int tni ; int tni ; } ecapseman
=============================================

The error message mainline used to give was:

:1:C.C:1: error: redefinition of `int <unnamed>::tni'
:1:C.C:1: error: `int <unnamed>::tni' previously declared here
:1:C.C:1: internal compiler error: tree check: expected class 'd', have 'x'
(error_mark) in cp_parser_init_declarator, at cp/parser.c:10717
Please submit a full bug report, [etc.]
Comment 5 Wolfgang Bangerth 2004-08-17 21:44:07 UTC
Extremely cool. Also the choice of filename is very innovative. 
 
I'm almost thinking we should have a metabug for cases like this. In 
the spirit of PR 5 :-) 
Comment 6 Mark Mitchell 2004-08-18 03:28:36 UTC
Working on a fix.
Comment 7 GCC Commits 2004-08-18 18:25:24 UTC
Subject: Bug 17068

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-08-18 18:25:10

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

Log message:
	PR c++/17068
	* pt.c (dependent_template_p): Treat IDENTIFIER_NODEs as
	dependent.
	
	PR c++/17068
	* g++.dg/template/operator4.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4281&r2=1.4282
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.907&r2=1.908
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4155&r2=1.4156
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/operator4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 9 Mark Mitchell 2004-08-18 18:34:45 UTC
Fixed in GCC 3.4.2.