Update regarding the Nullable issue

Simen Kjærås simen.kjaras at gmail.com
Thu Jul 12 08:54:17 UTC 2018


On Wednesday, 11 July 2018 at 10:43:40 UTC, FeepingCreature wrote:
> Destructors are not called for fields embedded in unions.
>
> On the one hand this is a horrible, horrible hack. On the 
> other, whee!

Not only a horrible hack, but a bug, and something you really 
can't rely on working in the future. Especially since this 
behavior is only observed with named unions, not with anonymous 
ones.

I'll also mention section 14.19 2 on the Structs, Unions page 
(https://dlang.org/spec/struct.html):

2. Unions may not have fields that have destructors.

Whether that means it's undefined behavior or the compiler should 
statically disallow it is up for debate, I guess.

--
   Simen


More information about the Digitalmars-d-announce mailing list