diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-01-18 13:58:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-18 13:58:00 +0100 |
| commit | b78edd7957190cc8db3e3af43e0a4a5375ffdf79 (patch) | |
| tree | 930ed03caea5ceea08cec1e9fcd811ada76028c1 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | bd62a452f45c2386275c5469f9ae390e7de2dc6f (diff) | |
| parent | e1dda100570f6b4cb9553fa2542472aeaac72c1c (diff) | |
| download | rust-b78edd7957190cc8db3e3af43e0a4a5375ffdf79.tar.gz rust-b78edd7957190cc8db3e3af43e0a4a5375ffdf79.zip | |
Rollup merge of #133700 - RalfJung:const-non-null, r=lcnr
const-eval: detect more pointers as definitely not-null This fixes https://github.com/rust-lang/rust/issues/133523 by making the `scalar_may_be_null` check smarter: for instance, an odd offset in any 2-aligned allocation can never be null, even if it is out-of-bounds. More generally, if an allocation with unknown base address B is aligned to alignment N, and a pointer is at offset X inside that allocation, then we know that `(B + X) mod N = B mod N + X mod N = X mod N`. Since `0 mod N` is definitely 0, if we learn that `X mod N` is *not* 0 we can deduce that `B + X` is not 0. This is immediately visible on stable, via `ptr.is_null()` (and, more subtly, by not raising a UB error when such a pointer is used somewhere that a non-null pointer is required). Therefore nominating for `@rust-lang/lang.`
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
