This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: friend declaration implicitly provides a prototype
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: "Bernardo Innocenti" <bernie at develer dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Wed, 17 Dec 2003 12:32:55 +0100
- Subject: Re: friend declaration implicitly provides a prototype
- References: <3FDF71C7.5070207@develer.com>
Bernardo Innocenti <bernie@develer.com> wrote:
> class Foo
> {
> // No prototype for bar() given
> friend void bar(int);
> };
>
> void some_function()
> {
> bar(10); // No error for undeclared function!
> }
>
>
> What the standard explicitly requires is that bar()
> can be accessed in Foo as if it was declared.
> This doesn't mean bar(int) is implicitly declared
> everywhere, right?
The friend declaration introduces a predeclaration in the enclosing namespace,
but the function should not be found under unqualified lookup until it's
declared (see §7.3.1.2/3). I think this is a known problem in GCC, but would
you please file a bugreport anyway, so that we're sure it doesn't get lost?
Thanks
Giovanni Bajo