What is going on here?
Shachar Shemesh via Digitalmars-d
digitalmars-d at puremagic.com
Wed Mar 4 05:43:38 PST 2015
import std.stdio;
struct A {
int a = 3;
this( int var ) {
a += var;
}
~this() {
writeln("A down ", a);
}
}
struct B {
A a;
this( int var ) {
a = A(var+1);
throw new Exception("An exception");
}
}
void main()
{
try {
auto b = B(2);
} catch( Exception ex ) {
}
}
I'd expect A's destructor to run, which does not seem to be the case.
Compiled with dmd 2.066.1
Shachar
More information about the Digitalmars-d
mailing list