Problem with overload resolution.
scott snyder
snyder@d0sgif.fnal.gov
Sat May 23 18:37:00 GMT 1998
hi -
This is relevant to egcs-2.91.29 on a mips-sgi-irix6.2 platform,
checked out fri. morning.
The following input:
-- bug37.cc ------------------------------------------------------------------
class it {};
class ci {};
class list {
public:
it end();
ci end() const;
void insert(it position);
};
class d0_List_1
: public list
{
public:
void append () {
insert (end());
}
};
------------------------------------------------------------------------------
Gives the error
bug37.cc:19: no matching function for call to `d0_List_1::insert (ci)'
bug37.cc:10: candidates are: list::insert(it)
The compiler appears to be choosing the wrong candidate for the
overloaded end() method in this instance. The error goes away
if the declaration
ci end() const;
is removed.
This seems to me to be incorrect according to the rules in [over.ics.rank]:
--Standard conversion sequence S1 is a better conversion sequence than
standard conversion sequence S2 if
--S1 and S2 differ only in their qualification conversion and yield
similar types T1 and T2 (_conv.qual_), respectively, and the cv-
qualification signature of type T1 is a proper subset of the cv-
qualification signature of type T2, [Example:
int f(const int *);
int f(int *);
int i;
int j = f(&i); // Calls f(int *)
thanks,
sss
More information about the Gcc-bugs
mailing list