top | item 46443995

(no title)

whytevuhuni | 2 months ago

Not quite, because depending on the compiler implementation / memory model, other things can also lead to UB, and thus be unsafe, e.g.:

* data races in a multi-threaded program

* type-casting to the wrong type (e.g. via unions) with compiler optimizations that rely on proper types

* assuming values are absolutely never aliased (shared xor mutable) when there's actually a way to create aliased values (e.g. unsafe {} and raw pointers)

* creating objects out of a sequence of bytes that is not valid for their type

...and likely many others I can't remember.

discuss

order

No comments yet.