Bogus name lookup by overloaded operators
Martin v. Loewis
Fri Mar 10 14:53:00 GMT 2000
> The gcc 2.95.2 seems to mix up the unary and binary operators during name
Thanks for your bug report. I believe this is a bug in your code, not
in g++. 188.8.131.52/3 specifies:
# If T1 is a class type, the set of member candidates is the result of
# the qualified lookup of T1::operator@ (184.108.40.206.1);
In 'c*c', T1 is C, which is a class type, so we look for C::operator*
according to the rule in 220.127.116.11.1. This is carried-out according to
the rules for looking up class members in 10.2. Here they say
# If the resulting set of declarations are not all from subÃÂobjects of
# the same type, or the set has a nonstatic member and includes
# members from distinct subÃÂobjects, there is an ambiguity and the
# program is illÃÂformed.
Hence the error.
> I've already started to doubt that these operators should be treated as
> lexically distinct, but then found a similar example in the Standard,
> par. 18.104.22.168.10. Thus I consider it's yet a bug.
The example demonstrates that 'a+a' looks for A::operator+, so it is a
qualified lookup. As a result, the shadowing of A::operator+ by
B::operator+ (which would normally happen) has no effect.
More information about the Gcc-bugs