[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [csmith-project/csmith] 717b1c: Fixed a bug related to --no-math64 and --no-longlo...
Here's my problem with unions. The standard says this:
"When a value is stored in a member of an object of union type, the
bytes of the object representation that do not correspond to that member
but do correspond to other members take unspecified values."
I think this means that if we have this union:
union {
int x;
float y;
} u;
we can't use the union to do type casting like this:
u.x = 3;
return u.y;
This creates a problem for us:
case 1: we follow the standard. this is very boring.
case 2: We don't follow the standard and we do generate code that does
type casts using unions. I think compilers support this. Now we have
to know alignment and size information for the target platform. This
makes Csmith output non-portable in two ways. First, it will be
specific to that target. Second, it won't conform to the standard.
John