Destructor called while object is still alive

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Oct 23 18:18:40 UTC 2020


On Fri, Oct 23, 2020 at 01:47:34PM -0400, Steven Schveighoffer via Digitalmars-d wrote:
[...]
> If DMD isn't smart enough to see that the reference may have escaped,
> then it shouldn't elide storage.
> 
> Under this view, I think actually the OP's case is a problem. Because
> Bar.create() could potentially be saving the result into a C heap
> block, in which case eliding the pointer storage is potentially going
> to cause memory corruption.
> 
> The optimizer is wrong, and should be changed.
> 
> Note that LDC does not do this optimization.
[...]

Yet another reason for me to avoid DMD and use LDC instead...


T

-- 
This sentence is false.


More information about the Digitalmars-d mailing list