This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/10337: "ambiguous overload"-error for non-ambiguous situation
- From: stip at mathematik dot uni-ulm dot de
- To: gcc-gnats at gcc dot gnu dot org
- Date: 7 Apr 2003 12:05:46 -0000
- Subject: c++/10337: "ambiguous overload"-error for non-ambiguous situation
- Reply-to: stip at mathematik dot uni-ulm dot de
>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
>Closed-Date:
>Last-Modified:
>Originator: Alexander Stippler
>Release: unknown-1.0
>Organization:
>Environment:
Solaris 2.9
gcc 3.2
>Description:
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;
}
>How-To-Repeat:
g++ convtest.cc
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: