[Issue 22324] New: Destructor not called on an array of structs
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 20 07:09:18 UTC 2021
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 at puremagic.com
Reporter: ogion.art at 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.
--
More information about the Digitalmars-d-bugs
mailing list