
union U
{
	char bytes[1];
	struct {
		int a;
		float b;
	} data;
};

int main()
{
	U foo;
	foo.data.a = 4;
	foo.data.b = 5.0;

	// Accessing foo.bytes here is undefined because it was
	// not the most recently written field of the union.
	char c0 = foo.bytes[0]; // INVALID!
	
	// This is ok
	U* bar = &foo;
	char c1 = bar->bytes[1];
	
	// This is ok too
	char c2 = ((U*)&foo)->bytes[2];

	// Is this ok?
	char c3 = (&foo)->bytes[3];

	return c0 + c1 + c2 + c3;
}

