=void in struct definition
Johan Engelen
j at j.nl
Mon Apr 9 17:19:37 UTC 2018
On Monday, 9 April 2018 at 11:06:50 UTC, Shachar Shemesh wrote:
> struct S {
> int a;
> int[5000] arr = void;
> }
>
> void func() {
> S s;
> }
>
> During the s initialization, the entire "S" area is
> initialized, including the member arr which we asked to be =
> void.
>
> Is this a bug?
Could be optimized, yes, provided that the spec is updated. We
discussed this live at the end of my DConf talk last year, and
Walter (in audience) agreed upon the needed spec change. I
haven't had/taken the time to work on it yet :(
The optimization of simplifying the initialization isn't too
hard. But it is a bit tricky, Johannes wrote down some good
points here: https://issues.dlang.org/show_bug.cgi?id=15951
(note the padding bytes issue). The good news is that there
doesn't appear to be any spec about it, so technically there is
no language breakage and currently it is an "accepts invalid"
bug...
Over dinner me, deadalnix and some others discussed further
optimization where emission of the large S.init could be
eliminated. We worked out some details, but it's a little harder
thing to do.
cheers,
Johan
More information about the Digitalmars-d
mailing list