This 4.1 regression is going to break one of the proposed benchmarks in 
spec2005. I believe that we have established that this code 
----------------------------- 
template <class T> void f (T &,       void (T::*)()      ); 
template <class T> void f (const T &, void (T::*)() const); 
 
struct X { 
    void g() const; 
}; 
 
const X *x; 
 
int main () { 
  f (*x, &X::g); 
} 
-------------------------------- 
is valid because the pointer to the constant member &X::g can't match the 
first template (it wants a non-const pointer-to-member). The code is accepted 
by all previous gcc versions, but with present mainline I get this: 
spec/src> c++ -c x.cc 
x.cc: In function &#8216;int main()&#8217;: 
x.cc:11: error: call of overloaded &#8216;f(const X&, void 
(X::*)()const)&#8217; is 
ambiguous 
x.cc:1: note: candidates are: void f(T&, void (T::*)()) [with T = const X] 
x.cc:2: note:                 void f(const T&, void (T::*)()const) [with T = 
X] 
 
Too bad... 
 
W.

-- 
           Summary: [4.1 regression] Spurious ambiguity with pointers to
                    members
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at dealii dot org
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to