Bug 8007 - typeof(...) as template arg doesn't work
Summary: typeof(...) as template arg doesn't work
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks: 12604
  Show dependency treegraph
 
Reported: 2002-09-22 18:26 UTC by sneechy
Modified: 2007-10-03 21:54 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-01-15 21:09:54


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sneechy 2002-09-22 18:26:00 UTC
The following three lines of code:

template <typename T> struct A;
struct B { int f (); };
void g () { A<typeof(B::f)> a; }

Result in an internal compiler error:

Internal compiler error in walk_tree, at tree-inline.c:1315

Release:
gcc version 3.2 (mingw special 20020817-1)

Environment:
Windows XP, gcc configure options: --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=f77,c++,objc,ada --disable-win32-registry --disable-shared

How-To-Repeat:
Compile the three lines of code (see problem description).
Comment 1 sneechy 2002-09-22 18:26:00 UTC
Fix:
I don't have a clue..
Comment 2 Kriang Lerdsuwanakij 2002-09-28 06:57:44 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.
Comment 3 Wolfgang Bangerth 2002-11-01 14:02:21 UTC
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/8007: Internal compiler error in walk_tree
Date: Fri, 1 Nov 2002 14:02:21 -0600 (CST)

 Whoever looks at this should also look at PRs 5750 and 4526.
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 

Comment 4 Wolfgang Bangerth 2003-05-01 14:34:04 UTC
From: Wolfgang Bangerth <bangerth@ices.utexas.edu>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/8007
Date: Thu, 1 May 2003 14:34:04 -0500 (CDT)

 The ICE has been fixed between 3.2 and 3.2.3, as well as in 3.3 and 3.4. 
 However, the code still doesn't compile. See also PR 10585.
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                                www: http://www.ices.utexas.edu/~bangerth/
 
 

Comment 5 Wolfgang Bangerth 2003-05-01 15:51:40 UTC
From: Wolfgang Bangerth <bangerth@ices.utexas.edu>
To: gcc-gnats@gcc.gnu.org, Giovanni Bajo <giovannibajo@libero.it>
Cc:  
Subject: Re: c++/8007
Date: Thu, 1 May 2003 15:51:40 -0500 (CDT)

 I don't know whether the code is legal (modulo the fact that typeof is an 
 extension). It works if one uses typeof(&B::f), but not with typeof(B::f). 
 Aren't there references to member functions? If not, shouldn't it just 
 decay to a pointer-to-member-function?
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                                www: http://www.ices.utexas.edu/~bangerth/
Comment 6 Giovanni Bajo 2003-05-01 20:28:13 UTC
From: "Giovanni Bajo" <giovannibajo@libero.it>
To: <gcc-gnats@gcc.gnu.org>,
	<gcc-bugs@gcc.gnu.org>,
	<nobody@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>,
	<sneechy@hotmail.com>
Cc:  
Subject: Re: c++/8007: Internal compiler error in walk_tree
Date: Thu, 1 May 2003 20:28:13 +0200

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8007
 
 The ICE is now gone on both 3.3 and 3.4, and the code is rejected. The only
 reason why I keep this PR open is that I'm not sure if the code is legal or
 not. With GCC 2.95, A<> gets instantiated as A<int (B::)()>, which I am not
 sure it's a legal type. Can some GCC extension guru comment on this?
 
 Giovanni Bajo
 

Comment 7 Andrew Pinski 2007-08-12 02:02:48 UTC
Trunk gives:
t.cc: In function 'void g()':
t.cc:3: error: invalid use of non-static member function 'int B::f()'
t.cc:3: error: template argument 1 is invalid
t.cc:3: error: invalid type in declaration before ';' token
Comment 8 Jason Merrill 2007-10-03 21:54:16 UTC
The error the trunk gives is correct; this is not one of the allowed uses of a member function name in [expr.prim]p10.