September 20, 2021 [Issue 22324] New: Destructor not called on an array of structs | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22324 Issue ID: 22324 Summary: Destructor not called on an array of structs Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: ogion.art@gmail.com Code: struct S { import core.stdc.stdio; int data; this(int data) { this.data = data; printf("ctor\n"); } ~this() { printf("dtor\n"); } } S[1] f(int x) { return [S(x)]; } void main() { auto equals = f(42) == [S(42)]; } Output: ctor ctor The problem is present in DMD since 0.63 (0.62 isn’t correct either, calling destructor 3 times for 2 constructor calls). LDC is also affected. -- |
Copyright © 1999-2021 by the D Language Foundation