miri: ptr::swap_nonoverlapping can no longer copy pointers bytewise in latest miri

After updating miri from pre-1.60 to 1.62, I start getting those errors: https://github.com/tower120/any_vec/runs/6425015915?check_suite_focus=true (that branch runs OK with older MIRI)

Previously, miri had troubles with any raw pointer deference operations, for me. But I “fixed” that with ptr::copy_nonoverlapping - and it worked for miri. It looks like there was some support for std::ptr::* operations on miri side… Which is now gone…

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

Oh, but swap doesn’t take a parameter to do this N times… your work-around with 3 ptr::copy_nonoverlapping is probably the best option for now then.

If you found the problem - you don’t need that branch anymore?

Looking at the implementation of swap_nonoverlapping, this is indeed not surprising: it just copies the data one T at a time. Your T is u8, so this copies the pointers byte-per-byte, and Miri does not support this.

swap_nonoverlapping used to be implemented in a different way, that’s why you didn’t see these problems before.

I wonder if this is even a correct implementation, since it means this is a typed copy…