Opened 7 years ago

Last modified 3 years ago

#82 assigned defect

Wrong Overload Chosen — at Initial Version

Reported by: Rob Schluntz Owned by: a3moss
Priority: minor Component: cfa-cc
Version: 1.0 Keywords: resolver overload polymorphism
Cc:

Description

The following example currently chooses the signed ?-?, but should choose unsigned ?-?. I believe it’s getting there because it delays the conversion cost for arguments until getting to bsearch, so by this point signed ?-? and unsigned ?-? are still both candidates, and unsigned ?-? fails because E is bound to unsigned and signed */unsigned * do not unify.

forall( dtype E ) void bsearch( E key, const E * vals );
signed int ?-?( signed int, signed int );
unsigned int ?-?( unsigned int, unsigned int );

void f() {
  int iarr[10];
  bsearch( (unsigned int)10 - (unsigned int)0, iarr );
}

If you take the polymorphism away, the unsigned ?-? is chosen.

void bsearch( signed int key, const signed int * vals );  // chosen
void bsearch( unsigned key, const unsigned int * vals );
signed int ?-?( signed int, signed int );
unsigned int ?-?( unsigned int, unsigned int );           // chosen

void f() {
  int iarr[10];
  bsearch( (unsigned int)10 - (unsigned int)0, iarr );
} 

Change History (0)

Note: See TracTickets for help on using tickets.