Open
Description
pub fn foo() -> (usize, usize, bool) {
let a: *const u8;
let b: *const u8;
{
let v: [u8; 16] = [std::hint::black_box(4); 16];
a = &(v[0]);
}
{
let v: [u8; 16] = [std::hint::black_box(4); 16];
b = &(v[0]);
}
(a as usize, b as usize, a == b)
}
fn main() {
println!("{:?}", foo());
}
I expected to see this happen: Either the pointers (when cast to integers) are the same and the comparison is true
, or they are not the same and the comparison is false
.
Instead, this happened: It printed: (140728325198984, 140728325198984, false)
Meta
Reproduced via rustc +nightly -Copt-level=3 test.rs && ./test
.
rustc --version --verbose
:
rustc 1.69.0-nightly (5b8f28453 2023-02-12)
binary: rustc
commit-hash: 5b8f284536d00ba649ca968584bedab4820d8527
commit-date: 2023-02-12
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7
Also reproduces on master.
@rustbot label +I-unsound +T-compiler +A-llvm
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Category: issue that is caused by bugs in software beyond our controlIssue: Correct Rust code lowers to incorrect machine codeIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessHigh priorityRelevant to the compiler team, which will review and decide on the PR/issue.Working group: LLVM backend code generation