Destructor called while object is still alive

Johan Engelen j at j.nl
Fri Oct 23 23:33:59 UTC 2020


On Friday, 23 October 2020 at 21:55:36 UTC, Ola Fosheim Grøstad 
wrote:
> On Friday, 23 October 2020 at 19:36:38 UTC, H. S. Teoh wrote:
>> On Fri, Oct 23, 2020 at 07:23:03PM +0000, frame via 
>> Digitalmars-d wrote:
>>> On Friday, 23 October 2020 at 17:47:34 UTC, Steven 
>>> Schveighoffer wrote:
>> [...]
>>> > The optimizer is wrong, and should be changed.
>>> > 
>>> > Note that LDC does not do this optimization.
>> [...]
>>> So how can I avoid this issue with DMD? Disabling any 
>>> optimization? In fact it does not occur with debug mode 
>>> enabled.
>> [...]
>>
>> IMNSHO, drop dmd and use ldc2 instead.  Life is too short to 
>> have to deal with dmd backend bugs when I'm trying to get 
>> things *done*.  This isn't the first time the dmd backend has 
>> problems when optimization / inlining are enabled, and I fear 
>> it won't be the last.
>
> LDC is better at detecting unreachable code so it actually does 
> worse than DMD.

I would certainly expect so. Same for GDC.

We can fix this in LDC (quite easily it looks like. We can force 
LLVM to put&keep certain pointers on the stack), but I first 
would like to see consensus about this issue from the language 
designers and see it in text in the language spec.

-Johan




More information about the Digitalmars-d mailing list