Struct Union behavior
Voitech via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jan 6 04:59:25 PST 2016
On Wednesday, 6 January 2016 at 12:25:31 UTC, Nicholas Wilson
wrote:
> Probably because you are accessing uninitialised memory. the
> values 4,5,9 appear in the first unittest and are left on the
> stack. Unions ,unlike structs, do not initialise their fields
> because it does not make sense to do so because the memory
> aliases. This can be observed by looking at the size of element
> (16 bytes) which is less than the size of an array (on 64 bit
> systems) , 2*8 bytes plus size of a real (8 or 10 bytes
> (x86/64)).
>
> [...]
Thank you for your answer it was very helpful :)
Cheers.
More information about the Digitalmars-d-learn
mailing list