From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29357 invoked by alias); 8 Jan 2003 16:46:10 -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 29313 invoked by uid 71); 8 Jan 2003 16:46:09 -0000 Resent-Date: 8 Jan 2003 16:46:09 -0000 Resent-Message-ID: <20030108164609.29312.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, bangerth@ticam.utexas.edu Received: (qmail 26380 invoked by uid 61); 8 Jan 2003 16:40:07 -0000 Message-Id: <20030108164007.26379.qmail@sources.redhat.com> Date: Wed, 08 Jan 2003 16:46:00 -0000 From: bangerth@ticam.utexas.edu Reply-To: bangerth@ticam.utexas.edu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/9230: Friend definitions in template classes X-SW-Source: 2003-01/txt/msg00544.txt.bz2 List-Id: >Number: 9230 >Category: c++ >Synopsis: Friend definitions in template classes >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Jan 08 08:46:07 PST 2003 >Closed-Date: >Last-Modified: >Originator: Wolfgang Bangerth >Release: unknown-1.0 >Organization: >Environment: all versions of gcc >Description: 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(); } -------------------------- 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? W. >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: