Using CSmith 2.3.0, I find I can get structs with bitfields created like this:
/* --- Struct/Union Declarations --- */
struct S0 {
unsigned f0 : 1;
signed f1 : 20;
};
The use of 'signed' and 'unsigned' (rather than the typedefs of uint16_t, int16_t, uint32_t, etc) here is causing me a problem.
I am using a cross-compiler, and in the example code above the compile fails as 'signed' is 16 bit wide, and hence a 20 bit wide bitfield fails. In the generated code, if I change 'signed' to 'int32_t' everything works as expected (including getting a checksum that matches against another compiler that has 32 bit signed).
So I am wondering of this struct should really be generated as something like:
struct S0 {
uint16_t f0 : 1; // or could be uint32_t?
int32_t f1 : 20;
};
I do apologize if this is not a bug but a consequence of how I have built CSmith. I am one of those brave souls that have succeed in building under Window 10 and am testing a Windows cross-compiler against the MS Visual Studio compiler.
Best regards,
Dennis