From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30734 invoked by alias); 17 Jan 2008 13:35:40 -0000 Received: (qmail 30720 invoked by uid 22791); 17 Jan 2008 13:35:40 -0000 X-Spam-Check-By: sourceware.org Received: from fk-out-0910.google.com (HELO fk-out-0910.google.com) (209.85.128.184) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 17 Jan 2008 13:35:22 +0000 Received: by fk-out-0910.google.com with SMTP id 26so428405fkx.8 for ; Thu, 17 Jan 2008 05:35:19 -0800 (PST) Received: by 10.82.112.3 with SMTP id k3mr3636946buc.31.1200576919299; Thu, 17 Jan 2008 05:35:19 -0800 (PST) Received: by 10.82.173.1 with HTTP; Thu, 17 Jan 2008 05:35:19 -0800 (PST) Message-ID: <84fc9c000801170535k1bd3eb89p6f95d63ee6f58647@mail.gmail.com> Date: Thu, 17 Jan 2008 14:46:00 -0000 From: "Richard Guenther" To: "Dragan Milenkovic" Subject: Re: A simple sample code involving templates, friends and lookup Cc: gcc@gcc.gnu.org In-Reply-To: <478F544F.9060509@plusplus.co.yu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <478F3175.2050809@plusplus.co.yu> <84fc9c000801170449j332abd0bp501bbc2fd9d04c46@mail.gmail.com> <478F544F.9060509@plusplus.co.yu> X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2008-01/txt/msg00264.txt.bz2 On Jan 17, 2008 2:12 PM, Dragan Milenkovic wrote: > Richard Guenther wrote: > [snip] > >> template > >> struct Foo > >> { > >> template > >> friend void func(const Foo &); > >> }; > >> > >> void check(const Foo & x) > >> { > >> // Foo weird; // uncomment this line and all works > >> > >> func(x); // <-- ERROR > >> } > >> > >> > >> Tested with gcc 4.0 - 4.3, and all behave the same: > >> > >> "error: 'func' was not declared in this scope" > >> > >> but it works if you uncomment the weird line. > > > > Actually even with the weird line the program is invalid. What are > > you trying to do? ;) > > > > Richard. > > Ok... afaik, that func should be defined on that very place where it is > declared as friend. But could you please elaborate why it is invalid, > since you made me start questioning my C++ knowledge... :-D How should name-lookup find func? Richard.