Destructor called while object is still alive
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Fri Oct 23 13:58:04 UTC 2020
On Friday, 23 October 2020 at 13:48:52 UTC, Boris Carvajal wrote:
> On Friday, 23 October 2020 at 13:34:56 UTC, Ola Fosheim Grøstad
> wrote:
>> On Friday, 23 October 2020 at 13:23:18 UTC, Boris Carvajal
>> wrote:
>>> exit() is irrelevant, I checked the asm output.
>>
>> Ok, I guess GC.collect() is called after main() by the runtime
>> then.
>
> Just to clarify my point.
> I was talking about 'scope foo = Bar.create();' that does
> nothing, neither the class is stack allocated nor the pointer
> is kept until the end of the function.
I understand.
I guess the goal of @safe makes the expected semantics for scope
(explicit destruction) impossible.
The compiler does not know if there are more references to the
scope-pointed object. D would need an "isolated" pointer type for
that.
I think an ARC implementation written for C++ shared_ptr would
have been interesting for class-objects, but it is not on the
table...
More information about the Digitalmars-d
mailing list