s***@mathematik.uni-ulm.de
2003-04-07 12:05:46 UTC
Number: 10337
Category: c++
Synopsis: "ambiguous overload"-error for non-ambiguous situation
Confidential: no
Severity: serious
Priority: medium
Responsible: unassigned
State: open
Class: rejects-legal
Submitter-Id: net
Arrival-Date: Mon Apr 07 12:06:00 UTC 2003
Originator: Alexander Stippler
Release: unknown-1.0
Solaris 2.9Category: c++
Synopsis: "ambiguous overload"-error for non-ambiguous situation
Confidential: no
Severity: serious
Priority: medium
Responsible: unassigned
State: open
Class: rejects-legal
Submitter-Id: net
Arrival-Date: Mon Apr 07 12:06:00 UTC 2003
Originator: Alexander Stippler
Release: unknown-1.0
gcc 3.2
convtest.cc:25: ambiguous overload for `B& = C&' operator
convtest.cc:9: candidates are: void B::operator=(const A&)
convtest.cc:10: void B::operator=(const B&)
The second assignment operator (line 10) has to be chosen IMO because of section 13.3.3.2/3 of the standard. Compiles with gcc 3.3 / 3.4 but emits warnings (why?)
class A {
public:
A() {}
};
class B : public A {
public:
B() {}
void operator=(const A& b) {}
void operator=(const B& b) {}
};
class C {
public:
C() {}
operator B &() { return _b; }
operator const B &() const { return _b; }
B _b;
};
int main() {
B b;
C c;
b = c;
}
g++ convtest.cc