appending newly initialized struct to array

Ali Çehreli acehreli at yahoo.com
Tue Apr 17 21:55:23 PDT 2012


On 04/17/2012 02:00 PM, simendsjo wrote:

 > Sounds like a bug. C style initializers work in other cases:

I try not to use them. I think they have this 'feature' of leaving 
unspecified members uninitialized:

struct S
{
     int i;
     double d;
}

void main()
{
     S s = { 42 };               // <-- no initializer for S.d
     assert(s.i == 42);
     assert(s.d == double.nan);  // <-- fails (may work for you)
}

Is that a bug or a feature? I might have opened it but I don't remember 
now. :)

Ali



More information about the Digitalmars-d-learn mailing list