File tree 6 files changed +49
-9
lines changed 6 files changed +49
-9
lines changed Original file line number Diff line number Diff line change
1
+ struct B
2
+ {
3
+ } b [1 ];
4
+ struct c
5
+ {
6
+ void * d ;
7
+ } e = {b };
8
+ struct
9
+ {
10
+ struct c f ;
11
+ } * g ;
12
+ int main ()
13
+ {
14
+ g -> f ;
15
+ }
Original file line number Diff line number Diff line change
1
+ CORE broken-smt-backend
2
+ main.c
3
+ --pointer-check
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION FAILED$
7
+ --
8
+ ^warning: ignoring
9
+ Invariant check failed
10
+ --
11
+ Taking the address of an empty struct resulted in an invariant failure in
12
+ address-of flattening. This test was generated using C-Reduce plus some further
13
+ manual simplification.
Original file line number Diff line number Diff line change
1
+ #include <string.h>
2
+
3
+ struct a
4
+ {
5
+ } b ()
6
+ {
7
+ struct a * c ;
8
+ memcpy (c + 2 , c , 1 );
9
+ }
10
+ int main ()
11
+ {
12
+ b ();
13
+ }
Original file line number Diff line number Diff line change @@ -126,6 +126,10 @@ exprt boolbvt::bv_get_rec(
126
126
dest.operands ().swap (op);
127
127
return dest;
128
128
}
129
+ else
130
+ {
131
+ return array_exprt{{}, to_array_type (type)};
132
+ }
129
133
}
130
134
else if (type.id ()==ID_struct_tag)
131
135
{
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ bool bv_pointerst::convert_address_of_rec(
138
138
139
139
// get size
140
140
auto size = pointer_offset_size (array_type.subtype (), ns);
141
- CHECK_RETURN (size.has_value () && *size > 0 );
141
+ CHECK_RETURN (size.has_value () && *size >= 0 );
142
142
143
143
offset_arithmetic (bv, *size, index );
144
144
CHECK_RETURN (bv.size ()==bits);
@@ -342,7 +342,7 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr)
342
342
else
343
343
{
344
344
auto size_opt = pointer_offset_size (pointer_sub_type, ns);
345
- CHECK_RETURN (size_opt.has_value () && *size_opt > 0 );
345
+ CHECK_RETURN (size_opt.has_value () && *size_opt >= 0 );
346
346
size = *size_opt;
347
347
}
348
348
}
Original file line number Diff line number Diff line change @@ -670,13 +670,8 @@ optionalt<exprt> get_subexpression_at_offset(
670
670
671
671
// no arrays of non-byte-aligned, zero-, or unknown-sized objects
672
672
if (
673
- !elem_size_bits.has_value () || *elem_size_bits == 0 ||
674
- *elem_size_bits % 8 != 0 )
675
- {
676
- return {};
677
- }
678
-
679
- if (*target_size_bits <= *elem_size_bits)
673
+ elem_size_bits.has_value () && *elem_size_bits > 0 &&
674
+ *elem_size_bits % 8 == 0 && *target_size_bits <= *elem_size_bits)
680
675
{
681
676
const mp_integer elem_size_bytes = *elem_size_bits / 8 ;
682
677
const auto offset_inside_elem = offset_bytes % elem_size_bytes;
You can’t perform that action at this time.
0 commit comments