Are padding bits always zero?
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jun 24 05:41:47 PDT 2017
On 6/24/17 4:44 AM, Honey wrote:
> Hi everyone!
>
> Are there any guarantees about the values of padding bits in structs?
>
> Thanks,
> Honey
Any padding bits between fields should be 0 as long as the struct is
initialized (i.e. as long as you don't do Struct s = void).
Padding bits after the fields I assume would be 0, but I don't know if
this is defined. It's possible the compiler doesn't consider those bits
to be part of the struct, and just there for alignment.
There is no spec for this, but I know that when the compiler has to fill
gaps with something it chooses 0.
-Steve
More information about the Digitalmars-d-learn
mailing list