Opened 11 months ago

Last modified 7 months ago

#194 new defect

Ambiguous reference vs pointer return [from ticket #70]

Reported by: Thierry Delisle Owned by:
Priority: major Component: cfa-cc
Version: 1.0 Keywords:

Description (last modified by mlbrooks)

forall( dtype T | sized(T) ) T * foo( void ) {
	printf( "foo1\n" );
	return (T *)0;
forall( dtype T | sized(T) ) T & foo( void ) {
	printf( "foo2\n" );
	return (T &)*(T *)0;
int main( void ) {
    int * i = foo();

This should not be ambiguous, one side is an exact match.
This must be either unambiguous or an error to define both

The reported ambiguity is between:

foo1 with T as int (return is T*, which is int*, assigned into int* variable)

foo2 with T as int* (return is T&, which is int*&, assigned into int* variable)

The reported cost is ( 0, 0, 0, 0, 1, 0, 0 ). It is surprising that the second case, which we wish to reject, has a zero reference-cost element (last position). It seems that assignment from X& to X should count one change of reference level.

Change History (1)

comment:1 Changed 7 months ago by mlbrooks

Description: modified (diff)
Note: See TracTickets for help on using tickets.