Description
Currently we have an awkward situation where heap::EMPTY
(1 as *mut _
) is frequently used to represent zero-sized types or other "non-allocations". It is often desirable to offset-by-0 from this in general code to avoid complicating things with special-cases for ZSTs or empty array iterators.
Unfortunately it is possible to interpret the LLVM GEP docs to determine that heap::EMPTY.offset(0)
(which is marked as inbounds unconditionally) has undefined behaviour, because heap::EMPTY is not actually allocated. I see two ways forward for this: mark heap::EMPTY
as allocated in some way for LLVM, or ensure offset(0)
is always safe. I favour the latter, simply because it's plausible to want to offset by 0 off some other ptrs. However the former is acceptable if this is not possible.