Bug 8702 - [3.3 regression] matching of conversion operators
Summary: [3.3 regression] matching of conversion operators
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3
: P1 critical
Target Milestone: ---
Assignee: Nathan Sidwell
URL:
Keywords: rejects-valid
: 8572 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-11-25 08:46 UTC by Craig Rodrigues
Modified: 2003-07-25 17:33 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
testcase1.tar.gz (1.87 KB, application/x-gzip )
2003-05-21 15:16 UTC, Craig Rodrigues
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Rodrigues 2002-11-25 08:46:01 UTC
The following testcase compiles fine with
gcc 2.95, gcc 3.1, and gcc 3.2.

With gcc 3.3, the following error occurs:

=============================================================
In file included from a1.h:128,
                 from a.h:13,
                 from a.cpp:1:
a1.inl:123: error: no `TAO::Utils::Auto_Functor<X, Functor>::operator
   TAO::Utils::Auto_Functor_Ref<Y, Functor>()' member function declared in
   class `TAO::Utils::Auto_Functor<X, Functor>'
a1.inl:123: error: template definition of non-template `
   TAO::Utils::Auto_Functor<X, Functor>::operator
   TAO::Utils::Auto_Functor_Ref<Y, Functor>()'
=============================================================

Release:
gcc 3.3

Environment:
FreeBSD 4.7:
Thread model: posix
gcc version 3.3 20021014 (experimental) [FreeBSD]


MacOS X 10.2.2
gcc version 3.3 20021120 (Apple Computer, Inc. build 1301)

How-To-Repeat:
Testcase includes a Makefile, just type make.
Comment 1 Wolfgang Bangerth 2002-11-25 09:15:52 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: True. It's a regression on mainline. Here's a reduced
    testcase:
    ------------------------------------
    template <typename X> struct C1{};
    
    template <typename X>
    struct C2 {
        template<typename Y> operator C1<Y>();
        template<typename Y> operator C2<Y>();
    };
    
    
    template<typename X> template<typename Y>
    C2<X>::operator C1<Y>()
    {
      return C1<Y>();
    }
    ---------------------------------
    
    gcc3.3 complains when seeing the definition of the 
    conversion operator.It is apparently confused by the
    second conversion operator, since if I remove that 
    declaration, everything is fine. 3.2.1 and 2.95 accept 
    the code as is.
    
    More on conversion operators and templates:
      PRs 383, 8572, 8578
Comment 2 Craig Rodrigues 2002-11-26 11:47:47 UTC
From: Craig Rodrigues <rodrigc@attbi.com>
To: bangerth@dealii.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
   nobody@gcc.gnu.org, rodrigc@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/8702: [3.3 regression] matching of conversion operators
Date: Tue, 26 Nov 2002 11:47:47 -0500

 On Mon, Nov 25, 2002 at 05:15:54PM -0000, bangerth@dealii.org wrote:
 >     True. It's a regression on mainline. Here's a reduced
 >     testcase:
 >     ------------------------------------
 >     template <typename X> struct C1{};
 >     
 >     template <typename X>
 >     struct C2 {
 >         template<typename Y> operator C1<Y>();
 >         template<typename Y> operator C2<Y>();
 >     };
 >     
 >     
 >     template<typename X> template<typename Y>
 >     C2<X>::operator C1<Y>()
 >     {
 >       return C1<Y>();
 >     }
 >     ---------------------------------
 
 That's a very good testcase.  It isolates the problem well.
 Can you prepare a patch to add this to the GCC testsuite?
 I think it should go under: gcc/testsuite/g++.dg/template/
 If you prefer, I can create a patch and submit it to gcc-patches@gcc.gnu.org.
 
 Thanks.
 --
 Craig Rodrigues        
 http://www.gis.net/~craigr    
 rodrigc@attbi.com

Comment 3 Wolfgang Bangerth 2002-11-26 11:55:51 UTC
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Craig Rodrigues <rodrigc@attbi.com>
Cc: gcc-bugs@gcc.gnu.org, <gcc-prs@gcc.gnu.org>, <rodrigc@gcc.gnu.org>,
   <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/8702: [3.3 regression] matching of conversion operators
Date: Tue, 26 Nov 2002 11:55:51 -0600 (CST)

 > >     True. It's a regression on mainline. Here's a reduced
 > >     testcase:
 > >     ------------------------------------
 > >     [snip]
 > >     ---------------------------------
 > 
 > That's a very good testcase.  It isolates the problem well.
 > Can you prepare a patch to add this to the GCC testsuite?
 
 Volker and I, and recently Christian, have been preparing many such
 testcases. I think this is not special, there should be dozens like this.
 But thanks anyway :-)
 
 > I think it should go under: gcc/testsuite/g++.dg/template/
 > If you prefer, I can create a patch and submit it to gcc-patches@gcc.gnu.org.
 
 I have no experience with such things, so I'd appreciate it if you would 
 do that for me.
 
 However, as far as I understand it, the testcases from PRs have been added
 usually upon fixing them, not before. I don't know whether there is a
 general policy. If testcases are added before, then one would need to
 state their name in the PR, and the PR in the testcase. I just wondered
 why you wanted exactly this testcase in the testsuite.
 
 I leave it up to you to do with it whatever you please.
 
 Regards
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 
Comment 4 Nathan Sidwell 2002-11-29 01:49:00 UTC
Responsible-Changed-From-To: unassigned->nathan
Responsible-Changed-Why: my patch of 2002-03-16 PR c++/4361 broke it.
    Craig has a test case at http://gcc.gnu.org/ml/gcc-patches/2002-11/msg01691.html
Comment 5 janis187 2002-12-16 17:29:30 UTC
From: Janis Johnson <janis187@us.ibm.com>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, nathan@gcc.gnu.org,
   rodrigc@gcc.gnu.org, gcc-bugs@gcc.gnu.org
Cc:  
Subject: Re: c++/8702: [3.3 regression] matching of conversion operators
Date: Mon, 16 Dec 2002 17:29:30 -0800

 The regression reported in PR c++/8702 showed up starting
 with this patch:
 
 2002-03-16  Nathan Sidwell  <nathan@codesourcery.com>
 
         PR c++/4361
         * cp-tree.h
         * call.c
         * class.c
         * lex.c
         * mangle.c
         * pt.c
         * search.c
         * typeck.c
 
 I used the test case that Wolfgang provided earlier in
 this PR.
 
 Output from the compiler:
 
 8702.C:12: error: no `C2<X>::operator C1<Y>()' member
    function declared in class `C2<X>'
 8702.C:12: error: template definition of non-template
    `C2<X>::operator C1<Y>()'
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8702
 
 
 
Comment 6 Nathan Sidwell 2002-12-24 14:11:43 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: 2002-12-24  Nathan Sidwell  <nathan@codesourcery.com>
    
    	PR c++/9053
    	* decl.c (duplicate_decls): Templates may be disambiguated by
    	return type.
    	
    	PR c++/8702
    	* decl2.c (check_classfn): Use lookup_fnfield_1. List all
    	conversion operators on failure.
Comment 7 Nathan Sidwell 2002-12-24 22:12:17 UTC
From: nathan@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8702
Date: 24 Dec 2002 22:12:17 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	nathan@gcc.gnu.org	2002-12-24 14:12:17
 
 Modified files:
 	gcc/cp         : ChangeLog decl.c decl2.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/lookup: decl1.C decl2.C 
 
 Log message:
 	cp:
 	PR c++/9053
 	* decl.c (duplicate_decls): Templates may be disambiguated by
 	return type.
 	
 	PR c++/8702
 	* decl2.c (check_classfn): Use lookup_fnfield_1. List all
 	conversion operators on failure.
 	testsuite
 	* g++.dg/lookup/decl1.C: New test.
 	* g++.dg/lookup/decl2.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3089&r2=1.3090
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.970&r2=1.971
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.578&r2=1.579
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2275&r2=1.2276
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/decl1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/decl2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 

Comment 8 Nathan Sidwell 2002-12-24 22:44:43 UTC
From: nathan@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8702
Date: 24 Dec 2002 22:44:43 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	nathan@gcc.gnu.org	2002-12-24 14:44:43
 
 Modified files:
 	gcc/cp         : ChangeLog decl.c decl2.c cp-tree.h call.c 
 	                 parse.y 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/lookup: decl1.C decl2.C scoped3.C 
 
 Log message:
 	cp:
 	PR C++/7964
 	* cp-tree.h (resolve_scoped_fn_name): Prototype.
 	* call.c (resolve_scoped_fn_name): New function. Deal with
 	more template expansion. Broken out of ...
 	* parse.y (parse_finish_call_expr): ... here. Call it.
 	* decl2.c (build_expr_from_tree, CALL_EXPR): Use
 	resolve_scoped_fn_name and build_call_from_tree.
 	
 	PR c++/9053
 	* decl.c (duplicate_decls): Templates may be disambiguated by
 	return type.
 	
 	PR c++/8702
 	* decl2.c (check_classfn): Use lookup_fnfield_1. List all
 	conversion operators on failure.
 	testsuite
 	* g++.dg/lookup/scoped3.C: New test.
 	
 	* g++.dg/lookup/decl1.C: New test.
 	* g++.dg/lookup/decl2.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.7&r2=1.3076.2.8
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.1&r2=1.965.2.2
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.575.2.2&r2=1.575.2.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.776.2.2&r2=1.776.2.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.341&r2=1.341.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parse.y.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.284.2.2&r2=1.284.2.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.7&r2=1.2261.2.8
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/decl1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/decl2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/scoped3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1