New -ffriend-injection behavior - is it really intended?

Brian Dessent brian@dessent.net
Thu May 24 21:10:00 GMT 2007


Daniel Lohmann wrote:

> 3) How do you read from the standard that a friend function defined in a
> class *can* be found from the enclosing namespace (only) by argument
> dependent lookup (as stated in the -ffriend-injection documentation)?
> 
> 4) And finally, do you know the *intention* behind all this? I am trying to
> imagine a good reason for the g++ 4.1 interpretation, but haven't been able
> to find one so far. I mean, it is just not a strong point for some
> interpretation if it obviously does not make sense...

I think you can find some language-lawyering on the topic here:
<http://www.open-std.org/JTC1/sc22/wg21/docs/cwg_closed.html#95>.  As
far as I understand it, the original early C++ standard (Annotated C++
Reference/ARM) called for name injection, but this was changed during
the drafting of the formal ISO C++ spec, which is but one of a number of
incompatibilities between the two standards.  I'm not sure of the
rationale but if you dig around on the wg21 site you should be able to
find more.

The gcc bug report tracking the change:
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7874>.  Note that it was
actually a regression in gcc 3.x against 2.95 that was never reconciled
until 4.1.  So this really is nothing new at all, it's just that
removing functionality in a compiler requires a deprecation period and a
lot of waiting.

Brian



More information about the Gcc-help mailing list