Description
After some inspection, the call to emit a check should go roughly here
The reason this isn't trivial is that any array_ptr<T> arr : count(x)
bounds are translated into array_ptr<T> arr : bounds(arr, arr + x)
, and we have to do code generation for both the lower and the upper bounds expression. For the upper expression in particular, this will mean we add a non-null check to arr
(the "base" pointer). We know this check is redundant, as we do a non-null check of arr
before we do the range check.
The sensible fix is probably to disable these non-null checks when generating the code for the upper and lower expressions. It is worth thinking about the soundness of this fix, in particular with respect to range checks that include pointer arithmetic on pointers that aren't the base pointer.