-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Miscompilation from .wrapping_offset(isize::MIN).wrapping_offset(isize::MIN) #112526
Copy link
Copy link
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-raw-pointersArea: raw pointers, MaybeUninit, NonNullArea: raw pointers, MaybeUninit, NonNullA-rustlantisArea: A miscompilation found by RustlantisArea: A miscompilation found by RustlantisI-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-raw-pointersArea: raw pointers, MaybeUninit, NonNullArea: raw pointers, MaybeUninit, NonNullA-rustlantisArea: A miscompilation found by RustlantisArea: A miscompilation found by RustlantisI-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Again, fuzzer generated code and minimised to surface Rust. Miri reports no UB under either aliasing model.
The correct output is 1, evaluated from
two >> *_31where_31points to 1 after having been roundtripped with two.wrapping_offset(isize::MIN).It outputs 2 with
-Copt-level >= 1.Not sure if rustc is emitting LLVM IR with UB or it's a bug in LLVM.
llvm-reducegave me this which callsdump_var(2)withopt -O1: https://godbolt.org/z/q6GWPq9qs, but the GEP indices don't look right.cc @RalfJung @nikic