bearophile wrote:

> A question about D1 specs (that may be useful for LDC).
> 
> In the following code there's anarray of structs S. Is it OK, according to
> D1 specs, to not initialize the memory of this array if the compiler sees
> that all fields of S have a void init?
> 
> struct S { double x = void, y = void; }
> void main() {
>   auto a = new S[1000];
> }
> 
> Bye,
> bearophile

That's an interesting question. The compiler does set void-initialized 
member variables to zeros:

struct S { double x = void, y = void; }
void main() {
    S s; // x and y are initialized to 0
}

I think this is a bug. Such members should be left uninitialized or 
initialized to the default initializer for the type (NaN in this case) or 
void initialization should be disallowed for member variables.

Reply via email to