Initializing an Immutable Field with Magic: The "Fake Placement New" Technique
FeepingCreature
feepingcreature at gmail.com
Fri Jul 26 14:48:42 UTC 2019
On Friday, 26 July 2019 at 14:19:11 UTC, ag0aep6g wrote:
> The pain points:
> 1) The spec doesn't say clearly when union fields are
> considered initialized.
> 2) DMD allows @safe access of (uninitialized) immutable union
> fields.
> 3) __ctor can be called on an existing instance in @safe code.
> That's clearly a bug.
I forgot to mention: none of this is @safe, of course. Manual
lifetime management is almost inherently unsafe. Which is why
Nullable is peppered with @trusted...
More information about the Digitalmars-d
mailing list