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.
Fix: Work-around: don't use the construct.
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. Rather funny. Martin, how do you find such constructs?
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/
Postponed until GCC 3.3.2.
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.
To try to fix this for GCC 3.3.2 will be too invasive; postponed until GCC 3.4.
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.
Move back the target for all regressions from 3.4.1 to 3.4.0, as required by our bug management policy.
Patch in progress...
Patch here, waiting for review: http://gcc.gnu.org/ml/gcc-patches/2004-01/msg01386.html
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
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
Fixed in GCC 3.4.0, and won't be fixed in the 3.3.x serie. Thanks for your report!