My memory is a little fuzzy on our last conversation about unions. But I think applying these 2 constraints on unions accesses could avoid undefined behaviors caused by padding bits:
1) after writing a field, reading must be through a field of equal or smaller size. i.e., writing to a int field and then reading from a char field is fine, but not the other way around.
2) after writing a struct field, reading must the through the same field.
I think with those we can avoid undefined behaviors without getting into messy details of types. Did I miss anything?
But you're going to need alignment information for everything to make
unions work, right?
On 05/04/2011 06:58 PM, Xuejun Yang wrote:
Yes, if we fix-size integers, the only thing left is pointers. That's why I was
asking. Well, I can fix it to 8 bytes for now if only unions care about it.
[mailto:email@example.com] On Behalf Of John Regehr
Sent: Wednesday, May 04, 2011 6:53 PM
Subject: Re: [csmith-project/csmith] 717b1c: Fixed a bug related to
Ok sorry to yell.
I grepped for x86_64 and it's not used much, so should be easy to eliminate.
Xuejun: are you going to need size/alignment information to make unions
work? For example, to avoid accessing padding bytes?