Topic: more on ambiguity...


Author: igodardA@TpacbellDO.Tnet ("Ivan Godard")
Date: Wed, 11 Aug 2004 03:13:06 GMT
Raw View
struct C{};
struct D{};
struct X {
    void Bar(C t) {}
    };
struct Y {
    void Bar(D t) {}
    };

struct R : public X, public Y {};
int main() {
    C c;
    D d;
    R r;

    r.Bar(c);
    r.Bar(d);
    return 0;
    }

The calls on Bar() are reported ambiguous. A kind person at gcc explained:

<[10.2]/2 states:

The following steps define the result of name lookup in class scope.
First, every declaration for the name in the class and in each of its
base class sub-objects is considered. [...] If the resulting set of
declarations are not all from sub-objects of the same type [...]
there is an ambiguity and the program is ill-formed. [...]

Overload resolution takes place later, see [10.2]/4.>

This seems singularly in-the-way. Can anyone explain the rationale for
having the standard this way? What would be the cost (and what programs
would break) if ambiguity reporting were deferred to after overload
resolution?

Ivan

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]