[csmith-dev] Alignment of struct members cause target dependent checksum
Kees Bakker
kees.bakker at altium.nl
Wed Jun 5 06:27:31 MDT 2013
Hi,
Csmith can generate tests with unions and struct where the result
is target dependent.
Here is a small example.
struct S1 {
const volatile uint8_t f10;
int32_t f11;
};
union U4 {
const uint32_t f0;
struct S1 f2;
};
static union U4 g_1126 = {4294967294UL};
One of the tests I created was writing in g_1126.f2.f11 and reading
from g_1126.f0 for the checksum.
However, the struct member offset of f11 is not defined. For example GCC (i386)
uses an offset 4, but other (compliant C99 compilers) may use offset 2 or even 1.
(And that is without specifying "pack".)
In this case the checksum created with GCC (assuming GCC is correct) is not
valid for all other compilers.
What options do I have to let Csmith avoid such a construct?
Kind regards,
Kees Bakker
More information about the csmith-dev
mailing list