g++ Koenig-lookup bug

Martin von Loewis martin@mira.isdn.cs.tu-berlin.de
Sun Oct 18 09:09:00 GMT 1998


> I think Koenig lookup should find both B::f and ::f, and  
> call ::f, here:
>   
>   struct A {};
>   void f(A&);
>   struct B {
>     void f(B&) { A a; f(a); }
>   };

No, it shouldn't. [basic.lookup.koenig]/2 sez

>> If the ordinary unqualified lookup of the name finds the
>> declaration of a class member function, the associated namespaces
>> and classes are not considered.

So we look for f, find B::f, and stop. Overload resolution then finds
no match.

Unfortunately, the standard rarely gives rationale; and I couldn't
come up with one, either.

Regards,
Martin



More information about the Gcc mailing list