On 11/09/2025 2:31 AM, IchorDev wrote:
On Wednesday, 10 September 2025 at 13:13:34 UTC, Richard (Rikki) Andrew Cattermole wrote:
The reason placement new is @system is because of double-init. It can't be a safe operation.

What?! Like, it assigns to the memory twice? What's the point of this feature, then? I thought this could essentially replace `emplace` for constructing types into uninitialised memory, but instead it's just a booby-trap that stops people from making their code `@safe`?

It does replace emplace, and just like emplace you can double-init memory with it. There is no protection against it apart from it being @system (which emplace should also be).

The caller is responsible for guaranteeing that the memory passed in is uninitialized, and that behavior is @system.
  • Placement new an... IchorDev via Digitalmars-d-learn
    • Re: Placeme... Dennis via Digitalmars-d-learn
      • Re: Pla... Paul Backus via Digitalmars-d-learn
        • Re:... IchorDev via Digitalmars-d-learn
      • Re: Pla... IchorDev via Digitalmars-d-learn
    • Re: Placeme... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: Pla... IchorDev via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... IchorDev via Digitalmars-d-learn
            • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
              • ... IchorDev via Digitalmars-d-learn
                • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
                • ... IchorDev via Digitalmars-d-learn
            • ... Paul Backus via Digitalmars-d-learn
              • ... IchorDev via Digitalmars-d-learn
                • ... Nick Treleaven via Digitalmars-d-learn

Reply via email to