Discussion:
c++/10337: "ambiguous overload"-error for non-ambiguous situation
s***@mathematik.uni-ulm.de
2003-04-07 12:05:46 UTC
Permalink
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.9
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
b***@dealii.org
2003-04-10 14:32:29 UTC
Permalink
Synopsis: "ambiguous overload"-error for non-ambiguous situation

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Thu Apr 10 14:32:29 2003
State-Changed-Why:
I tend to agree

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10337
Continue reading on narkive:
Search results for 'c++/10337: "ambiguous overload"-error for non-ambiguous situation' (Questions and Answers)
372
replies
WHAT IS 0 DIVIDED BY 0?
started 2016-01-12 20:36:57 UTC
mathematics
Loading...