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: 4.1.2 20060928 bug?: undefined overloaded friend function for function pointer


On Fri, Dec 15, 2006 at 07:48:29PM -0500, Andrew Pinski wrote:
> This is not an issue since this is actually invalid C++ and has already been documented
> on http://gcc.gnu.org/gcc-4.1/changes.html:
> # ARM-style name-injection of friend declarations is no longer the default. For example:
> 
>           struct S {
>             friend void f();
>           };
> 
>           void g() { f(); }

> will not be accepted; instead a declaration of f will need to be present
> outside of the scope of S. The new -ffriend-injection option will enable
> the old behavior.

Yes, I'd vaguely recalled this, which is why I thought of adding
real declarations of f().  But I still think that there is a bug here:
the error message produced is nonsense.

It looks like

q.C: In function ïïïïint main()ïïïï:
q.C:18: error: no matches converting function ïïïïfïïïï to type ïïïïvoid (*)(class A&, const int&)ïïïï
q.C:4: error: candidates are: void f(A&, const int&)
q.C:5: error:                 void f(A&)

However, this is false: neither declaration of f is a candidate, because
name-injection of friends is not allowed.  If they were candidates, the
first one would be an exact match and would be accepted.


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