This is the mail archive of the gcc-prs@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]

c++/10337: "ambiguous overload"-error for non-ambiguous situation


>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:


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