This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Call is not rejected as ambiguos


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]