Disagreeing addresses of `this`
Max Samukha
maxsamukha at gmail.com
Tue May 14 04:28:19 UTC 2024
On Tuesday, 14 May 2024 at 02:01:10 UTC, Longinus wrote:
> On Sunday, 12 May 2024 at 21:09:33 UTC, Nick Treleaven wrote:
>> * `p` is then bit-copied to `main.s`.
>
> Yeah this is the last time anything is done with `p`. Its
> destructor does not get called.
>
> I understand that avoiding this further copy may be an
> optimisation, but while I can have a dtor deal with an
> uninitialised object (by doing no-op), an initialised object
> not having its dtor called, that I don't know how to work with.
But the destructor does get called on each initialized object.
`s` is moved (not copied) into the uninitialized `__swap40` and
then the destructor is called on `__swap40`. Then `p` is moved
into `s` and the destructor is called on `s` at `main`'s exit.
Note that D mandates all struct objects be movable.
More information about the Digitalmars-d
mailing list