What should happen here?

Steven Schveighoffer schveiguy at gmail.com
Mon Sep 20 18:26:59 UTC 2021


Without any context, what do you think should happen here?

```d
import std.stdio;
import core.memory;
class C
{
    ~this() { writeln("dtor"); }
}

void main()
{
    auto c = new C;
    foreach(i; 0 .. 10000) GC.collect;
    writeln("end of main");
}
```

Option 1:
```
end of main
dtor
```

Option 2:
```
dtor
end of main
```

Option 3:
```
end of main
```

Option 4:
Option 1 or 2, depending on entropy.

I'll post a response with what I've observed, and further discussion. I 
just want people to consider the above only with their initial expectations.

-Steve


More information about the Digitalmars-d mailing list