This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: friend declaration implicitly provides a prototype


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]