https://issues.dlang.org/show_bug.cgi?id=23107
Issue ID: 23107 Summary: dtor incorrectly skipped Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: e...@weka.io struct Wrapper { // the bug only reproduces if there's an explicit ctor (in addition to the dtor): this(int* _dtors) { this.dtors = _dtors; } ~this() { ++*dtors; } int* dtors; alias dtors this; } int* explicit(int* dtors) { return Wrapper(dtors).dtors; } int* implicit(int* dtors) { return Wrapper(dtors); } unittest { bool check() { { int dtors; int* foo = explicit(&dtors); assert(foo == &dtors); assert(dtors == 1); // <-- assertion fails in CTFE only } { int dtors; int* foo = implicit(&dtors); assert(foo == &dtors); assert(dtors == 1); // <-- assertion fails in both CTFE and runtime } return true; } assert(check()); // static assert(check()); // <-- uncomment to get CTFE behavior validation too } --