Opened 7 years ago

Last modified 4 years ago

#88 new defect

Arrays of references — at Initial Version

Reported by: Rob Schluntz Owned by:
Priority: minor Component: cfa-cc
Version: 1.0 Keywords: reference array subscript
Cc:

Description

Currently the subscript operation does not work for arrays of references:

int main() {
  int & x[10];
  x[3];
}

$ cfa test.c
error: No reasonable alternatives for expression Applying untyped: 
  Name: ?[?]
...to: 
  Name: x
  constant expression (3 3: signed int)

This is because subscript is defined as

forall( dtype T | sized(T) ) T & ?[?]( T *, ptrdiff_t );

And type parameters do not currently bind to reference types. To make this work correctly, we want to allow bare type variables to strip references, but not otherwise.

Changing this line in bindVar in Unify.cc from

other = other->stripReferences();
}}
to
{{{
if ( widenMode.widenSecond ) other = other->stripReferences();
}}}
strips references for bare type parameters and not otherwise, as desired. For one reason or another this causes a 2x slowdown. 

Change History (0)

Note: See TracTickets for help on using tickets.