Opened 5 years ago
Last modified 5 years 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: | |
| Cc: |
Description (last modified by )
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.
Note:
See TracTickets
for help on using tickets.