Bug 23107 – dtor incorrectly skipped

Status
NEW
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-05-13T10:27:46Z
Last change time
2024-12-13T19:22:44Z
Assigned to
No Owner
Creator
Eyal
Moved to GitHub: dmd#20101 →

Comments

Comment #0 by eyal — 2022-05-13T10:27:46Z
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 }
Comment #1 by kinke — 2022-05-13T10:56:09Z
These are most likely 2 separate issues. The CTFE one is probably a duplicate of https://issues.dlang.org/show_bug.cgi?id=22536 (not restricted to array literals). And the runtime one related to `alias this`.
Comment #2 by robert.schadek — 2024-12-13T19:22:44Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20101 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB