Idomatic way to guarantee to run destructor?
Robert M. Münch
robert.muench at saphirion.com
Sat May 2 19:08:39 UTC 2020
On 2020-05-02 18:18:44 +0000, Steven Schveighoffer said:
> On 5/2/20 4:44 AM, Robert M. Münch wrote:
>
>> How would that help, because the class instance is now unusable anyway.
>> So I have it around like a zombie and others might think: "Hey you look
>> normal, let's get in contact" and then you are doomed...
>
> The difference is that if you use it, you get an error and a crash. If
> you clean up the memory, that memory could be reallocated to something
> else with a completely different type, and now you have memory
> corruption.
I didn't thought about the "memory is re-used" case here...
And how is the instance made unusable so that a crash happens (which I
prefer too!)? Does .destroy zero the memory? Just curious how the crash
situation is detected.
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
More information about the Digitalmars-d-learn
mailing list