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