This repository was archived by the owner on Apr 5, 2024. It is now read-only.
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
Clarify which inputs are permitted for the offset intrinsic (and the MIR binop) #38
Closed
Description
The offset intrinsic compiles to LLVM getelementpointer with inbounds
attribute, so the offset must stay in-bounds (or one-past-the-end). However, rustc currently also relies on "offset by 0" to always be legal, even if the pointer passed as input is dangling:
- In the IntoIterator impl for slices. If the slice is empty, the pointer will be
(void*) alignment
, but the iterator will still add the length (0
) to it. - The MIR emitted as slice drop glue does the same, but uses the MIR binop instead of the intrinsic.
So the rules for offset
currently seem to be:
- The resulting pointer has to be a valid, in-bounds pointer or one-past-the-end, OR
- the offset is 0.
Metadata
Metadata
Assignees
Labels
No labels