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]
Other format: [Raw text]

[Bug c++/36486] New: g++ accepts code with ambiguous overloading


g++ (at least versions 3.3.5, 3.4.4 and 4.1.1) accepts the following code,
which I think is ill-formed:


template<typename T> struct F {};

template<typename C, typename R>
int f(R (C::*f)() const, const F<R> &n = F<R>()) { return 0; } // f0

template<typename C, typename R>
int f(const R &(C::*f)() const, const F<R> &n = F<R>()) { return 1; } // f1

struct X { const X &foo() const { return *this; } };

int main() { return f(&X::foo); }


Here, g++ is presumably deciding that f1 is more specialized than f0, despite
f0's arguments not being deducible from f1 (indeed, there is no pair of
argument types (T1, T2) which both f0 and f1 accept).

EDG's frontend rejects the above code.


-- 
           Summary: g++ accepts code with ambiguous overloading
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: richard-gccbugzilla at metafoo dot co dot uk


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36486


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