File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
kani-compiler/src/codegen_cprover_gotoc/codegen Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -1308,13 +1308,19 @@ impl<'tcx> GotocCtx<'tcx> {
1308
1308
/// where "-" is wrapping subtraction, i.e., the result should be interpreted as
1309
1309
/// an unsigned value (2's complement).
1310
1310
fn wrapping_sub ( expr : & Expr , constant : u64 ) -> Expr {
1311
- if constant == 0 {
1312
- // No need to subtract.
1311
+ let unsigned_expr = if expr. typ ( ) . is_pointer ( ) {
1313
1312
expr. clone ( )
1314
1313
} else {
1315
1314
let unsigned = expr. typ ( ) . to_unsigned ( ) . unwrap ( ) ;
1316
- let constant = Expr :: int_constant ( constant, unsigned. clone ( ) ) ;
1317
- expr. clone ( ) . cast_to ( unsigned) . sub ( constant)
1315
+ expr. clone ( ) . cast_to ( unsigned)
1316
+ } ;
1317
+ if constant == 0 {
1318
+ // No need to subtract.
1319
+ // But we still need to make sure we return an unsigned value.
1320
+ unsigned_expr
1321
+ } else {
1322
+ let constant = Expr :: int_constant ( constant, unsigned_expr. typ ( ) . clone ( ) ) ;
1323
+ unsigned_expr. sub ( constant)
1318
1324
}
1319
1325
}
1320
1326
Original file line number Diff line number Diff line change 2
2
// SPDX-License-Identifier: Apache-2.0 OR MIT
3
3
//
4
4
//! Ensure that kani::any behaves correcty with NonZero types.
5
- //! This is currently failing due to some issue in the niche optimization.
6
- //! See <https://github.com/model-checking/kani/issues/1533> for more details.
7
5
8
6
use std:: num:: * ;
9
7
You can’t perform that action at this time.
0 commit comments