diff options
| author | Ralf Jung <post@ralfj.de> | 2024-07-03 16:04:37 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-07-04 14:12:23 +0200 |
| commit | 273d253ce6855381c9b7c36d3ea92581dd54becb (patch) | |
| tree | 9178b90843ca41134b29c79455905228382ea36e /compiler/rustc_const_eval | |
| parent | 7d97c59438e933e86f557ed999da3b8dfc6855a7 (diff) | |
offset_from: "the difference must fit in an isize" is a corollary
also, isize::MIN is an impossible distance
Diffstat (limited to 'compiler/rustc_const_eval')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intrinsics.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 1d54da267ee..d86f1a7a34f 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -301,9 +301,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { } // The signed form of the intrinsic allows this. If we interpret the // difference as isize, we'll get the proper signed difference. If that - // seems *positive*, they were more than isize::MAX apart. + // seems *positive* or equal to isize::MIN, they were more than isize::MAX apart. let dist = val.to_target_isize(self)?; - if dist >= 0 { + if dist >= 0 || i128::from(dist) == self.pointer_size().signed_int_min() { throw_ub_custom!( fluent::const_eval_offset_from_underflow, name = intrinsic_name, |
