File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed
regression/cbmc/void_pointer3 Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 1- CORE broken-smt-backend gcc-only
1+ CORE gcc-only
22main.c
33
44^EXIT=0$
Original file line number Diff line number Diff line change @@ -3825,11 +3825,23 @@ void smt2_convt::convert_minus(const minus_exprt &expr)
38253825 expr.op1 ().type ().id ()==ID_pointer)
38263826 {
38273827 // Pointer difference
3828- auto element_size =
3829- pointer_offset_size (to_pointer_type (expr.op0 ().type ()).base_type (), ns);
3830- CHECK_RETURN (element_size.has_value () && *element_size >= 1 );
3828+ const auto &base_type = to_pointer_type (expr.op0 ().type ()).base_type ();
3829+ mp_integer element_size;
38313830
3832- if (*element_size >= 2 )
3831+ if (base_type.id () == ID_empty)
3832+ {
3833+ // Pointer arithmetic on void is a gcc extension.
3834+ // https://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Pointer-Arith.html
3835+ element_size = 1 ;
3836+ }
3837+ else
3838+ {
3839+ auto element_size_opt = pointer_offset_size (base_type, ns);
3840+ CHECK_RETURN (element_size_opt.has_value () && *element_size_opt >= 1 );
3841+ element_size = *element_size_opt;
3842+ }
3843+
3844+ if (element_size >= 2 )
38333845 out << " (bvsdiv " ;
38343846
38353847 INVARIANT (
@@ -3843,8 +3855,8 @@ void smt2_convt::convert_minus(const minus_exprt &expr)
38433855 convert_expr (expr.op1 ());
38443856 out << " )" ;
38453857
3846- if (* element_size >= 2 )
3847- out << " (_ bv" << * element_size << " " << boolbv_width (expr.type ())
3858+ if (element_size >= 2 )
3859+ out << " (_ bv" << element_size << " " << boolbv_width (expr.type ())
38483860 << " ))" ;
38493861 }
38503862 else
You can’t perform that action at this time.
0 commit comments