@@ -12,9 +12,13 @@ use super::{ImmTy, Immediate, InterpCx, Machine, PlaceTy};
1212impl < ' mir , ' tcx : ' mir , M : Machine < ' mir , ' tcx > > InterpCx < ' mir , ' tcx , M > {
1313 /// Applies the binary operation `op` to the two operands and writes a tuple of the result
1414 /// and a boolean signifying the potential overflow to the destination.
15+ ///
16+ /// `force_overflow_checks` indicates whether overflow checks should be done even when
17+ /// `tcx.sess.overflow_checks()` is `false`.
1518 pub fn binop_with_overflow (
1619 & mut self ,
1720 op : mir:: BinOp ,
21+ force_overflow_checks : bool ,
1822 left : & ImmTy < ' tcx , M :: PointerTag > ,
1923 right : & ImmTy < ' tcx , M :: PointerTag > ,
2024 dest : & PlaceTy < ' tcx , M :: PointerTag > ,
@@ -26,6 +30,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
2630 "type mismatch for result of {:?}" ,
2731 op,
2832 ) ;
33+ // As per https://github.com/rust-lang/rust/pull/98738, we always return `false` in the 2nd
34+ // component when overflow checking is disabled.
35+ let overflowed =
36+ overflowed && ( force_overflow_checks || M :: check_binop_checks_overflow ( self ) ) ;
37+ // Write the result to `dest`.
2938 if let Abi :: ScalarPair ( ..) = dest. layout . abi {
3039 // We can use the optimized path and avoid `place_field` (which might do
3140 // `force_allocation`).
0 commit comments