friend declaration implicitly provides a prototype

Giovanni Bajo giovannibajo@libero.it
Wed Dec 17 14:22:00 GMT 2003


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




More information about the Gcc mailing list