This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++ 2.95.2 fails to detect ambiguity between member and non-member
- To: gcc bug list <gcc-bugs at gcc dot gnu dot org>
- Subject: g++ 2.95.2 fails to detect ambiguity between member and non-member
- From: Martin Sebor <sebor at roguewave dot com>
- Date: Thu, 23 Mar 2000 20:22:14 -0700
- CC: John Pedretti <pedretti at roguewave dot com>
Hi,
g++ 2.95.2 successfully compiles the ill-formed program below despite the
ambiguity between S::operator!() and ::operator!(const S&).
According to 13.3.1.2, p3, both operators are in the set of candidate functions
for the purposes of overload resolution.
According to 13.3.2, both functions are viable.
According to 13.3.3, p1, neither viable function is better than the other since
their arguments (i.e., the implicit object parameter of the member function, and
the formal argument of the non-member function) are identical: const S&.
Hence, according to 13.3.3, p2, the call is ill-formed.
Thanks
Martin
struct S
{
int operator! () const {
return 0;
}
};
int operator! (const S&)
{
return 1;
}
int main ()
{
return !S();
}