Skip to main content
6 events
when toggle format what by license comment
Jan 22, 2023 at 13:11 vote accept FZs
Jan 21, 2023 at 19:29 comment added Chayim Refael Friedman @FZs No, it is fine because it never uses references to overlapping memory.
Jan 21, 2023 at 19:21 comment added FZs @ChayimRefaelFriedman Is that issue also present in Matthieu's version that uses pointer arithmetic instead?
Jan 21, 2023 at 19:17 comment added FZs Oh, wow, that's a lot to take in. It's interesting that several of the mentioned issues originated from me not being "brave" enough to use pointer arithmetic and resorting to a pointer to the slice... Also, I did consider using NonNull, but I didn't feel qualified enough (the docs say "but is ultimately more dangerous to use because of its additional properties. If you’re not sure if you should use NonNull<T>, just use *mut T!"). And finally, I have to get into the habit of writing a lot of tests. I did write a basic one, but it was not at all comprehensive.
Jan 21, 2023 at 18:28 comment added Chayim Refael Friedman Miri doesn't complain about the references because they are valid according to Stacked Borrows, but there is still a problem: if somebody, concurrently, executes the code that materializes references, they will get two mutable references to the whole slice existing at the same time, which is UB.
Jan 21, 2023 at 16:27 history answered Matthieu M. CC BY-SA 4.0