File tree 2 files changed +12
-5
lines changed
regression/cbmc/Bitfields1
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -8,10 +8,10 @@ typedef enum _INTEL_CACHE_TYPE {
8
8
} INTEL_CACHE_TYPE ;
9
9
10
10
struct bft {
11
- unsigned int a : 3 ;
11
+ unsigned long int a : 3 ;
12
12
unsigned int b :1 ;
13
13
signed int c :2 ;
14
- _Bool d : 3 ;
14
+ _Bool d : 1 ;
15
15
16
16
// an anonymous bitfield
17
17
signed int :2 ;
@@ -20,7 +20,7 @@ struct bft {
20
20
INT x :1 ;
21
21
22
22
// made of sizeof
23
- unsigned int abc : sizeof (int );
23
+ unsigned int abc : sizeof (int ) * 8 ;
24
24
25
25
// enums are integers!
26
26
INTEL_CACHE_TYPE Type : 5 ;
@@ -53,7 +53,14 @@ int main() {
53
53
54
54
// assignments have the underlying type
55
55
assert (sizeof (bf .d = 1 )== sizeof (_Bool ));
56
- assert (sizeof (bf .a += 1 ) == sizeof (unsigned ));
56
+ assert (sizeof (bf .a += 1 ) == sizeof (unsigned long ));
57
57
58
58
bf .Type = IntelCacheTrace ;
59
+
60
+ // promotion rules apply, and thus, bf.a is signed,
61
+ // but bf.abc is unsigned
62
+ bf .a = 0 ;
63
+ assert (bf .a - 1 < 0 );
64
+ bf .abc = 0 ;
65
+ assert (bf .abc - 1 >= 0 );
59
66
}
Original file line number Diff line number Diff line change 1
- CORE
1
+ KNOWNBUG
2
2
main.c
3
3
4
4
^EXIT=0$
You can’t perform that action at this time.
0 commit comments