Closed
Description
Sometimes crates deliberately cause UB because there is no other way to do what they need, or because the alternatives are unacceptably worse in some sense. This is not great, but it is valuable feedback for us -- we should try to either make those things not UB, or provide UB-free alternatives that are good enough!
Some cases:
- crossbeam's
AtomicCell
does various things with uninitialized memory. Most of this would be fine if we allowed uninitialized integers and adapted LLVM's handling of data races, butcompare_exchange
is worse. bytes
does a non-atomic plain load that races, because relaxed loads cost too much performance. (Note that LLVM's handling of data races is not enough here, data races still return garbage data. Also see this thread on using "unordered".)- Every
offset_of
macro everywhere, in particular - Unwinding through FFI boundaries is used in
mozjpeg-sys
and possibly other image-related libs. One of many long discussions on the issue is here.
In this issue, please let's only discuss whether something is UB according to current rules. if you want to talk about ways to improve the code or the spec to avoid UB, open a new issue (or there might already be one).