https://issues.dlang.org/show_bug.cgi?id=704
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #11 from [email protected] --- Does this bug only apply for scope classes? I tested the following code on dmd git master: ------ class MyClass { this() { writeln("ctor"); throw new Exception(""); } ~this() { writeln("dtor"); } } void main() { try { scope c = new MyClass; } catch(Exception e) { // ignore } } ------ Only the ctor is called, not the dtor, because the ctor throws and does not properly construct the object. This is correct behaviour. However, changing `scope` to `auto` will cause the dtor to still be called, in spite of the ctor throwing an exception. According to Andrei's comment, this is wrong, since the object was not fully initialized, and the exception from the ctor should be taken to mean that construction of the object has been abandoned. Not sure if this belongs to this bug, though, or to a different bug, since the original complaint involved "auto" classes, which I'm assuming was the original name of scope classes. --
