Date: 20 Jan 2000 15:14:58 +0100 Original-Message-ID: <vs901kq17h.fsf@iar.se> Lines: 58 // // In the follwoing program GCC seems to forget the function // "Forgotten". In the function "foo" it can be called with objects // of type U1 and U2. But in "bar" it can only be called with "U2" // objects. // // It seems as GCC remembers only the prototype of the last usage of // the function "Forgotten" in the first function where it is used. (As // a compiler developer, I'd put my money on a faulty cache mechanism // in your function matching system.) // // Try the following: // Remove the namespace declaration. => // The program compiles with no errors. // Comment out function "foo". => Ditto. // Change U1 to U2 in "bar". => Ditto. // Swap order of the calls in in "foo". => Ditto. // Replace the friend form of "Forgotten" inside "Object" (Alt 1) // with the template function definition (Alt 2). => Ditto. // namespace MySpace { class Tag1 { }; class Tag2 { }; template<class Tag> class Object { public: // Alt 1: Broken: friend void Forgotten(Object const & m) { /* Do something */ } }; // Alt 2: This definition works: // template<class Tag> void Forgotten(Object<Tag> const & m) // { /* Do something */ } typedef Object<Tag1> U1; typedef Object<Tag2> U2; void foo() { Forgotten(U1()); Forgotten(U2()); } void bar() { Forgotten(U1()); } } Release: 2.95.2 Environment: Host type: Sun. Gcc version: 2.95.2 Command line parameters: None (expcept the name of the program).
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed as a bug
From: loewis@gcc.gnu.org To: andersl@iar.se, gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de, nobody@gcc.gnu.org Cc: Subject: Re: c++/78 Date: 9 Mar 2000 07:49:20 -0000 Old Synopsis: [not accepted] Problem with namespaces, templates, and friend functions. New Synopsis: Problem with namespaces, templates, and friend functions. State-Changed-From-To: open->analyzed State-Changed-By: loewis State-Changed-When: Wed Mar 8 23:49:20 2000 State-Changed-Why: Confirmed as a bug http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=78&database=gcc
State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed in CVS, with testcase friend10.C
From: neil@gcc.gnu.org To: andersl@iar.se, gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de, nobody@gcc.gnu.org Cc: Subject: Re: c++/78 Date: 2 Dec 2000 18:09:21 -0000 Synopsis: Problem with namespaces, templates, and friend functions. State-Changed-From-To: analyzed->closed State-Changed-By: neil State-Changed-When: Sat Dec 2 10:09:21 2000 State-Changed-Why: Fixed in CVS, with testcase friend10.C http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=78&database=gcc