@@ -12,9 +12,13 @@ use super::{ImmTy, Immediate, InterpCx, Machine, PlaceTy};
12
12
impl < ' mir , ' tcx : ' mir , M : Machine < ' mir , ' tcx > > InterpCx < ' mir , ' tcx , M > {
13
13
/// Applies the binary operation `op` to the two operands and writes a tuple of the result
14
14
/// 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`.
15
18
pub fn binop_with_overflow (
16
19
& mut self ,
17
20
op : mir:: BinOp ,
21
+ force_overflow_checks : bool ,
18
22
left : & ImmTy < ' tcx , M :: PointerTag > ,
19
23
right : & ImmTy < ' tcx , M :: PointerTag > ,
20
24
dest : & PlaceTy < ' tcx , M :: PointerTag > ,
@@ -26,6 +30,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
26
30
"type mismatch for result of {:?}" ,
27
31
op,
28
32
) ;
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`.
29
38
if let Abi :: ScalarPair ( ..) = dest. layout . abi {
30
39
// We can use the optimized path and avoid `place_field` (which might do
31
40
// `force_allocation`).
0 commit comments