Bug 8856 - [3.3/3.4 regression] g++ accepts invalid conversion-function-id
Summary: [3.3/3.4 regression] g++ accepts invalid conversion-function-id
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.1
: P3 normal
Target Milestone: 3.4.0
Assignee: giovannibajo
URL:
Keywords: accepts-invalid, patch
Depends on:
Blocks:
 
Reported: 2002-12-07 03:36 UTC by Martin v. Loewis
Modified: 2004-01-17 04:22 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-11-03 04:13:42


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin v. Loewis 2002-12-07 03:36:01 UTC
	The following program is accepted, even though operator double<int>
	is not a valid conversion-function-id (as double is not a template).

#include <stdio.h>

template <class T> struct A {
    template <class U> operator U() { return sizeof(U); }
};


int main() {
  A<double> a;
  int x = a.A<double>::operator int();
  double y = a.A<double>::operator double();
  int z = a.A<double>::operator double<int>();
  printf("%d %f %d\n", x, y, z);
}

Release:
3.1

Environment:
System: SunOS paros 5.9 Generic_112233-02 sun4u sparc SUNW,Sun-Blade-1000
Architecture: sun4

host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: ../configure --host=sparc-sun-solaris2.8 --enable-shared --enable-threads --with-cpu=v8 --with-gnu-ld --with-gnu-as --enable-version-specific-runtime-libs

How-To-Repeat:
	Compile the above program.
Comment 1 Martin v. Loewis 2002-12-07 03:36:01 UTC
Fix:
	Work-around: don't use the construct.
Comment 2 Wolfgang Bangerth 2002-12-09 11:17:54 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. Rather funny. Martin, how do you find such constructs?
Comment 3 Wolfgang Bangerth 2003-04-01 15:14:57 UTC
From: Wolfgang Bangerth <bangerth@ices.utexas.edu>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/8856
Date: Tue, 1 Apr 2003 15:14:57 -0600 (CST)

 Actually, this is a regression. 2.95 did not accept this code, we do since 
 3.0. 
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                                www: http://www.ices.utexas.edu/~bangerth/
Comment 4 Mark Mitchell 2003-07-11 22:14:51 UTC
Postponed until GCC 3.3.2.
Comment 5 Andrew Pinski 2003-07-15 13:13:39 UTC
According to Phil's regression hunter, it is has been accepting since at least 2000-12-31, 
so something before that makes this test be accepted.
Comment 6 Mark Mitchell 2003-09-17 20:58:12 UTC
To try to fix this for GCC 3.3.2 will be too invasive; postponed until GCC 3.4.
Comment 7 Andrew Pinski 2004-01-11 00:04:39 UTC
This has been failing for 3 years and no one really cares to fix it so moving to 3.4.1 so it 
does not block the branching.
Comment 8 Steven Bosscher 2004-01-12 23:39:34 UTC
Move back the target for all regressions from 3.4.1 to 3.4.0, as required by 
our bug management policy. 
Comment 9 Giovanni Bajo 2004-01-14 18:33:36 UTC
Patch in progress...
Comment 10 Giovanni Bajo 2004-01-15 00:53:28 UTC
Patch here, waiting for review:
http://gcc.gnu.org/ml/gcc-patches/2004-01/msg01386.html
Comment 11 GCC Commits 2004-01-15 01:40:07 UTC
Subject: Bug 8856

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	giovannibajo@gcc.gnu.org	2004-01-15 01:40:00

Modified files:
	gcc/cp         : ChangeLog parser.c 

Log message:
	PR c++/8856
	* parser.c (cp_parser_template_name): Don't try to parse a
	conversion-function-id, as it cannot be a template-name.
	(cp_parser_simple_type_specifier): Check for invalid template-ids
	even after a built-in type.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3880&r2=1.3881
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.154&r2=1.155

Comment 12 GCC Commits 2004-01-15 01:46:15 UTC
Subject: Bug 8856

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	giovannibajo@gcc.gnu.org	2004-01-15 01:46:11

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: casting-operator2.C 
Removed files:
	gcc/testsuite/g++.old-deja/g++.pt: explicit83.C 

Log message:
	PR c++/8856
	* g++.dg/parse/casting-operator2.C: New test.
	* g++.old-deja/g++.pt/explicit83.C: Remove.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3376&r2=1.3377
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/casting-operator2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.pt/explicit83.C.diff?cvsroot=gcc&r1=1.2&r2=NONE

Comment 13 Giovanni Bajo 2004-01-15 01:47:17 UTC
Fixed in GCC 3.4.0, and won't be fixed in the 3.3.x serie. Thanks for your 
report!