Disagreeing addresses of `this`

Longinus contact at lngnslnvsk.net
Tue May 14 02:01:10 UTC 2024


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.
My current work-around is to simply _not_ use temporaries, but 
it's awkward and I don't know how to make the compiler warn on 
their usage.
(For reference: yes, I'm literally having the ctor/dtor write 
`&this` in places; so this is introducing dangling pointers)

Thanks for looking into it.


More information about the Digitalmars-d mailing list