Second Draft: Placement New Expression
Paul Backus
snarwin at gmail.com
Wed Nov 20 03:28:06 UTC 2024
On Wednesday, 20 November 2024 at 01:49:23 UTC, Walter Bright
wrote:
> On 11/19/2024 11:02 AM, Paul Backus wrote:
>> Using a typed lvalue instead of void[] is just asking to shoot
>> yourself in the foot, especially when it comes to
>> const/immutable:
>
> This (and some other reasons) is why placement new will not be
> allowed in @safe code. The compiler will never be able to
> properly vet the provenance of the memory being overwritten by
> placement new.
I agree that it can't be @safe, void[] or not. But my impression
is that even in @system code, D generally tries to guide the
programmer away from error-prone constructs (for example,
requiring an explicit `= void` to leave a variable
uninitialized). Using a void[] instead of a typed lvalue would be
consistent with that approach.
More information about the dip.development
mailing list