You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CBMC version: 5.95.1
Operating system: Ubuntu 22.04
Exact command line resulting in the issue: cbmc --trace <example program below>
What behaviour did you expect: The size of the second struct should be 16 bytes.
What happened instead: CBMC thought the size is 6 bytes and reported a false alarm.
Example program:
#include<assert.h>#include<stdio.h>typedefstructExample_packed_s {
charc;
inti;
} __attribute__((packed)) Example_packed_t;
typedefstructExample_aligned_s {
charc;
Example_packed_ti __attribute__((aligned(8)));
} Example_aligned_t;
intmain() {
printf("Size of example packed struct = %ld\n", sizeof(Example_packed_t));
printf("Size of example aligned struct = %ld\n", sizeof(Example_aligned_t));
assert(sizeof(Example_packed_t) ==5);
assert(sizeof(Example_aligned_t) ==16);
return0;
}
It seems the packed attribute in the first struct also influenced the second struct and caused CBMC to pack the second member i in Example_aligned_t. (Therefore, the size is 1 + 5 = 6 bytes).
Violated property:
file compiler_atrribute_nested.c functionmain line 18 thread 0
assertion sizeof(Example_aligned_t) == 16
sizeof(Example_aligned_t) /*6ul*/ == (unsigned long int)16
GCC version gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 confirms that the size of the second struct is 16 bytes.
The text was updated successfully, but these errors were encountered:
Packing needs to be evaluated as part of the definition of the type
while alignment applies also when using a type. The position of the
attribute also requires extra care as some positions are accepted by GCC
(and warned about by Clang) while actually being ignored.
Fixes: diffblue#8443
CBMC version: 5.95.1
Operating system: Ubuntu 22.04
Exact command line resulting in the issue:
cbmc --trace <example program below>
What behaviour did you expect: The size of the second
struct
should be 16 bytes.What happened instead: CBMC thought the size is 6 bytes and reported a false alarm.
Example program:
It seems the
packed
attribute in the first struct also influenced the second struct and caused CBMC to pack the second memberi
inExample_aligned_t
. (Therefore, the size is 1 + 5 = 6 bytes).GCC version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
confirms that the size of the second struct is 16 bytes.The text was updated successfully, but these errors were encountered: