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 @@ -3837,11 +3837,23 @@ void smt2_convt::convert_minus(const minus_exprt &expr)
38373837 expr.op1 ().type ().id ()==ID_pointer)
38383838 {
38393839 // Pointer difference
3840- auto element_size =
3841- pointer_offset_size (to_pointer_type (expr.op0 ().type ()).base_type (), ns);
3842- CHECK_RETURN (element_size.has_value () && *element_size >= 1 );
3840+ const auto &base_type = to_pointer_type (expr.op0 ().type ()).base_type ();
3841+ mp_integer element_size;
3842+
3843+ if (base_type.id () == ID_empty)
3844+ {
3845+ // Pointer arithmetic on void is a gcc extension.
3846+ // https://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Pointer-Arith.html
3847+ element_size = 1 ;
3848+ }
3849+ else
3850+ {
3851+ auto element_size_opt = pointer_offset_size (base_type, ns);
3852+ CHECK_RETURN (element_size_opt.has_value () && *element_size_opt >= 1 );
3853+ element_size = *element_size_opt;
3854+ }
38433855
3844- if (* element_size >= 2 )
3856+ if (element_size >= 2 )
38453857 out << " (bvsdiv " ;
38463858
38473859 INVARIANT (
@@ -3855,8 +3867,8 @@ void smt2_convt::convert_minus(const minus_exprt &expr)
38553867 convert_expr (expr.op1 ());
38563868 out << " )" ;
38573869
3858- if (* element_size >= 2 )
3859- out << " (_ bv" << * element_size << " " << boolbv_width (expr.type ())
3870+ if (element_size >= 2 )
3871+ out << " (_ bv" << element_size << " " << boolbv_width (expr.type ())
38603872 << " ))" ;
38613873 }
38623874 else
You can’t perform that action at this time.
0 commit comments