Static initialization of static arrays is weird

Dennis dkorpel at gmail.com
Sun Aug 19 12:57:33 UTC 2018


On Sunday, 19 August 2018 at 12:10:08 UTC, kinke wrote:
> I think the spec is pretty clear; the elements of the 
> right-hand-side initializer array are interpreted as 
> per-element initializer, i.e., `result[0] = 2, result[1] = 1` 
> (rest: default-init).

I can't find where in the spec it says that the elements of the 
right-hand-side initializer array are interpreted as per-element 
initializer, or that the rest will be default initialized. But 
that would mean that this works:
```
int[3][3] arr = 0;
```
And it does for a local variable, but for a struct member it says 
(both dmd and ldc):
```
cannot implicitly convert expression 0 of type int to int[3][3]
```
So that should be fixed too.


More information about the Digitalmars-d-learn mailing list