This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Call is not rejected as ambiguos
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Call is not rejected as ambiguos
- From: Alexander Klimov <ask at ispras dot ru>
- Date: Mon, 17 Jan 2000 21:20:11 +0300 (MSK)
Program:
#include <stdio.h>
class A{};
class B : public A{};
B* b = 0;
void f3(void*){ puts(__PRETTY_FUNCTION__); }
void f3(A*){ puts(__PRETTY_FUNCTION__); }
main(){
f3(b);
}
Output:
void f3(A *)
gcc -v:
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.1/specs
gcc version 2.95.1 19990816 (release)
According to "The C++ Programing Language" by Straustrup, 3d edition,
p.149:
Finding the right version to call from a set of overloaded
functions ... series of criteria are tried in order:
....
[3] Match using standard conversions (...Derived* to Base*, T* to
void*, ..)
....
If two matches are found at the highest level where a match is found,
tha call is rejected as ambiguous.
Regards,
ASK