3 ms·
Can you provide a specific example or playground link? It seems like you'd still have to dereference it, which is unsafe, yes?
by TheDong 9y ago
Can you provide a specific example or playground link?
It seems like you'd still have to dereference it, which is unsafe, yes?
- cwzwarich 9y agoIf you read the linked LLVM documentation, you'll see that any LLVM instruction with side effects that depends on poison can trigger UB, e.g. a volatile store where the poison value is the stored value, not the address. I haven't tried very hard to write a seemingly safe Rust program using ptr:offset that LLVM will optimize into a crash. It's probably possible with a bit of work; this is basically C's signed overflow UB in a different guise, and programmer misunderstanding of that has caused serious bugs and security issues over the years.
- mahkoh 9y agoptr::offset is unsafe.