Confusing Miri error when byte_offset_from
is used on two different invalid pointers.
#3104
Labels
A-diagnostics
errors and warnings emitted by miri
C-enhancement
Category: a PR with an enhancement or an issue tracking an accepted enhancement
The following code causes Miri to emit an error that I think does not properly describe the issue.
It is confusing that Miri seems to complain about the pointer being dangling, since it does not complain when a dangling pointer is offset from itself. I believe the true issue is that they are not pointers to the same object, but the fact that they're not really pointers to objects at all makes the error less useful. Additionally, Miri is seemingly fine with the code if both of the pointers are
invalid
with the same integer and emitserror: Undefined Behavior: `ptr_offset_from` called on pointers into different allocations
if only one pointer is invalid and the other is a pointer to an object (including freed).I believe that this error should be the normal "
offset_from
called on pointers to different allocations" error. (perhaps with an additional note saying that the inputs are both invalid?)The text was updated successfully, but these errors were encountered: