Program crash: GC destroys an object unexpectedly
jfondren
julian.fondren at gmail.com
Wed Sep 22 10:05:05 UTC 2021
On Wednesday, 22 September 2021 at 08:03:59 UTC, eugene wrote:
> On Tuesday, 21 September 2021 at 20:28:33 UTC, jfondren wrote:
>>> Everything is Ok now,
>>
>> I don't think this is reliably OK. If you're not using Stopper
>> later in the function, and if there are no other references to
>> it, then the GC can collect it. It just has no obligation to
>> collect it, so minor differences like this might prevent that
>> from happening for particular compilers/options/versions.
>
> I saw a thread on this forum named
> 'Why are so many programmers do not like GC'
> or something like that.
>
> After this adventure I would add my 5 cents:
> because (sometimes, ok) it behaves absolutely
> unpredictable, depending on operation order,
> "particular compilers/options/versions" etc.
Nondeterminism in heap collection is a very common complaint, but
here we have data is that apparently on the stack that is
collected nondeterministically. I can't say I like that.
More information about the Digitalmars-d-learn
mailing list