File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -415,7 +415,7 @@ bool simplify_exprt::simplify_typecast(exprt &expr)
415
415
}
416
416
417
417
// Push a numerical typecast into pointer arithmetic
418
- // (T)(x + y ) ---> (T)((size_t)x + ( size_t)y )
418
+ // (T)(ptr + int ) ---> (T)((size_t)ptr + sizeof(subtype)*( size_t)int )
419
419
//
420
420
if ((expr_type.id ()==ID_signedbv || expr_type.id ()==ID_unsignedbv) &&
421
421
op_type.id ()==ID_pointer &&
@@ -428,13 +428,18 @@ bool simplify_exprt::simplify_typecast(exprt &expr)
428
428
const unsignedbv_typet size_t_type (config.ansi_c .pointer_width );
429
429
expr.op0 ().type ()=size_t_type;
430
430
431
- Forall_operands (it, expr.op0 ())
431
+ for ( auto & it : expr.op0 (). operands ())
432
432
{
433
- it->make_typecast (size_t_type);
434
-
435
- if (step>1 &&
436
- it->type ().id ()!=ID_pointer)
437
- *it=mult_exprt (from_integer (step, size_t_type), *it);
433
+ if (it.type ().id ()==ID_pointer)
434
+ {
435
+ it.make_typecast (size_t_type);
436
+ }
437
+ else
438
+ {
439
+ it.make_typecast (size_t_type);
440
+ if (step>1 )
441
+ it=mult_exprt (from_integer (step, size_t_type), it);
442
+ }
438
443
}
439
444
440
445
simplify_rec (expr);
You can’t perform that action at this time.
0 commit comments