This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

g++ 2.95.2 fails to detect ambiguity between member and non-member


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();
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]