zig
zig copied to clipboard
support pointer subtraction
Fixes #1738
I don't know if this should introduce a dedicated AIR instruction instead of emitting two int_from_ptr
and a sub_wrap
. This is also missing safety just like the existing pointer arithmetic but maybe that can be done as part of #1918? Otherwise, if those two things aren't a blocking issue I think this is more or less complete. It seems to work at least.
I also put an emphasis on introducing a clear distinction between "pointer-integer arithmetic" and "pointer subtraction" (pointer-pointer arithmetic) because both of those are "pointer arithmetic" so "pointer arithmetic" on its own becomes ambiguous.