File tree 3 files changed +30
-2
lines changed
regression/cbmc/Bitfields3
3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdlib.h>
2
+
3
+ struct A {
4
+ unsigned char a ;
5
+ unsigned char b :2 ;
6
+ unsigned char c :2 ;
7
+ } __attribute__((packed ));
8
+
9
+ int main (void )
10
+ {
11
+ struct A * p ;
12
+ p = malloc (2 );
13
+ p -> c = 3 ;
14
+ if (p -> c != 3 ) {
15
+ free (p );
16
+ }
17
+ free (p );
18
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --bounds-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -287,13 +287,15 @@ exprt member_offset_expr(
287
287
if (it->type ().id ()==ID_c_bit_field)
288
288
{
289
289
std::size_t w=to_c_bit_field_type (it->type ()).get_width ();
290
+ bit_field_bits += w;
290
291
std::size_t bytes;
291
- for ( bytes= 0 ; w> bit_field_bits; ++bytes, bit_field_bits+= 8 ) {}
292
- bit_field_bits-=w ;
292
+ bytes = bit_field_bits / 8 ;
293
+ bit_field_bits = bit_field_bits % 8 ;
293
294
result=plus_exprt (result, from_integer (bytes, result.type ()));
294
295
}
295
296
else
296
297
{
298
+ bit_field_bits = 0 ;
297
299
const typet &subtype=it->type ();
298
300
exprt sub_size=size_of_expr (subtype, ns);
299
301
if (sub_size.is_nil ())
You can’t perform that action at this time.
0 commit comments