File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ union U
2
+ {
3
+ void * ptr ;
4
+ __CPROVER_size_t n ;
5
+ };
6
+
7
+ int main ()
8
+ {
9
+ int * p = __CPROVER_allocate (sizeof (int ), 0 );
10
+ union U u = {.ptr = p };
11
+ __CPROVER_assert (u .n != 0 , "is not null" );
12
+ }
Original file line number Diff line number Diff line change
1
+ CORE new-smt-backend
2
+ main.c
3
+
4
+ Generated 1 VCC\(s\), 0 remaining after simplification
5
+ ^EXIT=0$
6
+ ^SIGNAL=0$
7
+ ^VERIFICATION SUCCESSFUL$
8
+ --
9
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -1897,6 +1897,43 @@ simplify_exprt::resultt<> simplify_exprt::simplify_inequality_rhs_is_constant(
1897
1897
}
1898
1898
}
1899
1899
}
1900
+
1901
+ if (config.ansi_c .NULL_is_zero )
1902
+ {
1903
+ const exprt &maybe_tc_op = skip_typecast (expr.op0 ());
1904
+ if (maybe_tc_op.type ().id () == ID_pointer)
1905
+ {
1906
+ // make sure none of the type casts lose information
1907
+ const pointer_typet &p_type = to_pointer_type (maybe_tc_op.type ());
1908
+ bool bitwidth_unchanged = true ;
1909
+ const exprt *ep = &(expr.op0 ());
1910
+ while (bitwidth_unchanged && ep->id () == ID_typecast)
1911
+ {
1912
+ if (auto t = type_try_dynamic_cast<bitvector_typet>(ep->type ()))
1913
+ {
1914
+ bitwidth_unchanged = t->get_width () == p_type.get_width ();
1915
+ }
1916
+ else
1917
+ bitwidth_unchanged = false ;
1918
+
1919
+ ep = &to_typecast_expr (*ep).op ();
1920
+ }
1921
+
1922
+ if (bitwidth_unchanged)
1923
+ {
1924
+ if (expr.id () == ID_equal || expr.id () == ID_ge || expr.id () == ID_le)
1925
+ {
1926
+ return changed (simplify_rec (
1927
+ equal_exprt{maybe_tc_op, null_pointer_exprt{p_type}}));
1928
+ }
1929
+ else
1930
+ {
1931
+ return changed (simplify_rec (
1932
+ notequal_exprt{maybe_tc_op, null_pointer_exprt{p_type}}));
1933
+ }
1934
+ }
1935
+ }
1936
+ }
1900
1937
}
1901
1938
1902
1939
// are we comparing with a typecast from bool?
You can’t perform that action at this time.
0 commit comments