Fixed size array initialization

rumbu rumbu at rumbu.ro
Sat Feb 10 10:55:30 UTC 2018


I know that according to language spec 
(https://dlang.org/spec/arrays.html#static-init-static) you can 
skip declaring all your elements in a fixed size array.

I'm just recovering from a bug which took me one day to discover 
because of this.

I have a large static initialized array, let's say int[155], and 
I forgot to declare the last element:

int[155] myarray = [
   a,
   b,
   c,
   ...
   //forgot to declare the 155th element
];

I took for granted that the compiler will warn me about the fact 
that my number of elements doesn't match the array declaration 
but I was wrong.

Does it worth to fill an enhancement on this, or this is intended 
behavior?



More information about the Digitalmars-d-learn mailing list