From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12484 invoked by alias); 8 Jan 2003 19:06:12 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 12431 invoked by uid 71); 8 Jan 2003 19:06:09 -0000 Date: Wed, 08 Jan 2003 19:06:00 -0000 Message-ID: <20030108190609.12427.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Gabriel Dos Reis Subject: Re: c++/9230: Friend definitions in template classes Reply-To: Gabriel Dos Reis X-SW-Source: 2003-01/txt/msg00554.txt.bz2 List-Id: The following reply was made to PR c++/9230; it has been noted by GNATS. From: Gabriel Dos Reis To: bangerth@ticam.utexas.edu Cc: gcc-gnats@gcc.gnu.org Subject: Re: c++/9230: Friend definitions in template classes Date: 08 Jan 2003 20:01:57 +0100 bangerth@ticam.utexas.edu writes: | I'm not sure about this one: | -------------------------- | template class X { | friend void f () {}; | }; | | void g() { f(); } | -------------------------- | This yields: | h.cc: In function `void g()': | h.cc:5: error: `f' undeclared (first use this function) | h.cc:5: error: (Each undeclared identifier is reported only once for each | function it appears in.) | | On the other hand, this compiles cleanly: | -------------------------- | template class X { | friend void f () {}; | }; | | template class X; | void g() { f(); } This is a bogus behaviour of g++ I came across from time to time. More generally, we have BIG problems in the current name-lookup implementation. | In other words, the function f() is injected into the global | namespace only upon the first instantiation of the template | class X. Is this the way it is supposed to be? No. There is no declaration of f() in the global scope. -- Gaby