You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: resources/deliberate-ub.md
+6
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,12 @@ We should evaluate whether there truly is some use-case here that is not current
34
34
There is a bunch of code out there that violates these rules one way or another.
35
35
All of these are resolved by [Tree Borrows](https://perso.crans.org/vanille/treebor/), though [some subtleties around `as_mut_ptr` do remain](https://github.com/rust-lang/unsafe-code-guidelines/issues/450).
36
36
37
+
### Other cases
38
+
39
+
*`gxhash` wants to do a vector-sized load that may go out-of-bounds, and didn't find a better solution than causing UB with an OOB load and then masking off the extra bytes.
40
+
See [here](https://github.com/ogxd/gxhash/issues/82) for some discussion and [here](https://github.com/ogxd/gxhash/blob/9eb19b021ff94a7b37beb5f479880d07e029b933/src/gxhash/platform/mod.rs#L18) for the relevant code.
41
+
The same [also happens in `compiler-builtins`](https://github.com/rust-lang/compiler-builtins/issues/559).
42
+
37
43
## Former cases of deliberate UB that have at least a work-in-progress solution to them
38
44
39
45
* Various `offset_of` implementations caused UB by using `mem::uninitialized()`, or they used `&(*base).field` or `addr_of!((*base).field)` to project a dummy pointer to the field which is UB due to out-of-bounds pointer arithmetic.
0 commit comments