[gnu.g++.bug] g++ allows ambigous member function overloading with default parameters

schmidt%crimee.ics.uci.edu@PARIS.ICS.UCI.EDU ("Douglas C. Schmidt") (01/02/89)

Hi,

   The following C++ code demonstrates a problem with g++ 1.32.

----------------------------------------
// overloaded functions are ambiguous.

#include <stream.h>

class Foo {
public:

   double i ( double = 10 ) { 
      cout << "hello, this is wrong!\n"; 
      return ( 10.0 );
   }

   int i ( int = 10 ) { 
      cout << "goodbye\n"; 
      return ( 1 ); 
   }

};

main ( int, char *[ ] ) {
   Foo Bar;
   int i = Bar.i(); // ambiguous call.
}
----------------------------------------

g++ compiles this without complaint, and then calls the *first* of the
two overloaded member functions ( i.e., it seems to follow the rule
that the first member function whose signature matches the call should
be used. ).  This seems rather arbitrary, and a warning message should
probably be given.  AT&T cfront 1.2.1. also gets this wrong, but at
least it gives a warning message to the effect that

int i = Bar.i() 

is attempting to assign a double to an int.

Doug