@@ -536,52 +536,34 @@ bool value_set_dereferencet::memory_model(
536
536
const typet from_type=value.type ();
537
537
538
538
// first, check if it's really just a type coercion,
539
- // i.e., both have exactly the same (constant) size
539
+ // i.e., both have exactly the same (constant) size,
540
+ // for bit-vector types or pointers
540
541
541
- if (is_a_bv_type (from_type) &&
542
- is_a_bv_type (to_type))
542
+ if (
543
+ (is_a_bv_type (from_type) && is_a_bv_type (to_type)) ||
544
+ (from_type.id () == ID_pointer && to_type.id () == ID_pointer))
543
545
{
544
546
if (pointer_offset_bits (from_type, ns) == pointer_offset_bits (to_type, ns))
545
547
{
546
548
// avoid semantic conversion in case of
547
549
// cast to float or fixed-point,
548
550
// or cast from float or fixed-point
549
551
550
- if (to_type.id ()==ID_fixedbv || to_type.id ()==ID_floatbv ||
551
- from_type.id ()==ID_fixedbv || from_type.id ()==ID_floatbv)
552
+ if (
553
+ to_type.id () != ID_fixedbv && to_type.id () != ID_floatbv &&
554
+ from_type.id () != ID_fixedbv && from_type.id () != ID_floatbv)
552
555
{
556
+ value = typecast_exprt::conditional_cast (value, to_type);
557
+ return true ;
553
558
}
554
- else
555
- return memory_model_conversion (value, to_type);
556
559
}
557
560
}
558
561
559
- // we are willing to do the same for pointers
560
-
561
- if (from_type.id ()==ID_pointer &&
562
- to_type.id ()==ID_pointer)
563
- {
564
- if (pointer_offset_bits (from_type, ns) == pointer_offset_bits (to_type, ns))
565
- return memory_model_conversion (value, to_type);
566
- }
567
-
568
562
// otherwise, we will stitch it together from bytes
569
563
570
564
return memory_model_bytes (value, to_type, offset);
571
565
}
572
566
573
- // / Make `value` into a typecast expression: `(to_type)value`
574
- // / \return true
575
- bool value_set_dereferencet::memory_model_conversion (
576
- exprt &value,
577
- const typet &to_type)
578
- {
579
- // only doing type conversion
580
- // just do the typecast
581
- value.make_typecast (to_type);
582
- return true ;
583
- }
584
-
585
567
// / Replace `value` by an expression of type `to_type` corresponding to the
586
568
// / value at memory address `value + offset`.
587
569
// /
0 commit comments