Beingessner: Rust's Unsafe Pointer Types Need An Overhaul
Beingessner: Rust's Unsafe Pointer Types Need An Overhaul
Posted Mar 22, 2022 18:27 UTC (Tue) by khim (subscriber, #9252)In reply to: Beingessner: Rust's Unsafe Pointer Types Need An Overhaul by jlombera
Parent article: Beingessner: Rust's Unsafe Pointer Types Need An Overhaul
> Again, "volatile" is to ask the *compiler* not to optimize access to memory in the generated binary code.
And that's not enough. Not even on x86. You know that, right?
Intel 8086 included lock prefix from the very beginning! And you can not force compiler to use it with volatile. End of story.
Yes, with C89 you had no choice but to use assembler with some volatile sprinkled here and there. C11 offers atomics which provide much more concise and usable semantic.
Don't use volatile except in kernel, please. It's not needed and harmful.
