This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Bogus name lookup by overloaded operators
- To: gawrilow at math dot TU-Berlin dot DE
- Subject: Re: Bogus name lookup by overloaded operators
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Fri, 10 Mar 2000 23:49:34 +0100
- CC: gcc-bugs at gcc dot gnu dot org
- References: <14536.62838.166885.791922@sokol.math.TU-Berlin.DE>
> The gcc 2.95.2 seems to mix up the unary and binary operators during name
> lookup.
Thanks for your bug report. I believe this is a bug in your code, not
in g++. 13.3.1.2/3 specifies:
# If T1 is a class type, the set of member candidates is the result of
# the qualified lookup of T1::operator@ (13.3.1.1.1);
In 'c*c', T1 is C, which is a class type, so we look for C::operator*
according to the rule in 13.3.1.1.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 subobjects of
# the same type, or the set has a nonstatic member and includes
# members from distinct subobjects, there is an ambiguity and the
# program is illformed.
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. 13.3.1.2.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.
Regards,
Martin