default initialization of char arrays
JN
666total at wp.pl
Wed Sep 10 23:35:29 UTC 2025
On Monday, 8 September 2025 at 15:42:27 UTC, Walter Bright wrote:
> This came up in an email exchange. Consider:
>
> ```
> import core.stdc.stdio;
>
> __gshared char[10] xxx = [0]; // initialize xxx to all zeros
>
I feel like in such scenario a warning should be issued, or even
compilation error, "static array initialization expects 10
values, only 1 provided". Sooner or later someone will hit the
same issue again and spend hours debugging why the array doesn't
get zeroed.
More information about the Digitalmars-d
mailing list