bug in overloading resolution in g++-2.95.1

Alexander Schiemann aschiem@count.math.uni-sb.de
Sun Sep 5 10:34:00 GMT 1999


egcs-1.1.* and gcc-2.95.1 have a bug concerning overload resolution. 
(egcs-1.0.3 was o.k.)
The following program does not compile but it should.
The error was already reported for egcs-1.1.1 and egcs-1.1.2.

Alexander Schiemann

<begin example>
struct A{};

struct B:A{};

struct C:B{};

struct CX{
C  c;

  operator C&(){return c;}

// viable functions for call below
void f(A&);
void f(B&);

int main()
{CX cx;
 C  c;

f(c);   // the standard conversion to B& is better than to A& 

f(cx);  // after user defined conversion to C&
        // the standard conversion to B& is better than to A& 

<end example>

hardware (pentium II 400Mhz):

# This directory was configured as follows:
--host=i686-pc-linux-gnu --prefix=/usr/local/lib/gcc-2.95.1
--enable-shared --enable-version-specific-runtime-libs --norecursion 
# using "mh-frag" and "mt-frag"

aschiem@kusma:~/Cage/cage-dev/g++-bugs/Test-programs > g++-2.95.1
over_res.cc: In function `int main()':
over_res.cc:39: call of overloaded `f (CX &)' is ambiguous
over_res.cc:30: candidates are: void f(A &)
over_res.cc:31:                 void f(B &)
aschiem@kusma:~ > g++-2.95.1 -v
Reading specs from
gcc version 2.95.1 19990816 (release)

More information about the Gcc-bugs mailing list