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


Hello

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):
MACHINE=i686
MACHTYPE=i586-pc-linux-gnu
OSTYPE=linux-gnu


# This directory was configured as follows:
../gcc-2.95.1/configure
--with-gcc-version-trigger=/tmp/gcc/gcc-2.95.1/gcc/version.c
--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"


OUTPUT:
aschiem@kusma:~/Cage/cage-dev/g++-bugs/Test-programs > g++-2.95.1
over_res.cc 
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
/usr/local/lib/gcc-2.95.1/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/specs
gcc version 2.95.1 19990816 (release)





More information about the Gcc-bugs mailing list