Re: Struct Union behavior

2016-01-06 Thread Voitech via Digitalmars-d-learn
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 b

Re: Struct Union behavior

2016-01-06 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 11:39:44 UTC, Voitech wrote: Hello, i am new to D language and trying to learn it by coding. I compile my programs on Xubuntu 14.04 with DMD64 D Compiler v2.069.2. So i have a struct/union which contains two fields representing real and string values: public un

Struct Union behavior

2016-01-06 Thread Voitech via Digitalmars-d-learn
Hello, i am new to D language and trying to learn it by coding. I compile my programs on Xubuntu 14.04 with DMD64 D Compiler v2.069.2. So i have a struct/union which contains two fields representing real and string values: public union Element { private real _value; private str