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.