No, it’s not guaranteed.
The only thing prohibiting any compiler from inserting padding between x
and y
, or between y
and z
is common sense. There is no rule in any language standard that would disallow it.
Even if there is no padding, even if the representation of A
is exactly the same as that of double[3]
, then it’s still not valid. The language doesn’t allow you to pretend one type is really another type. You’re not even allowed to treat an instance of struct A { int i; };
as if it’s a struct B { int i; };
.