[Issue 21478] New: Setting a default value to an object field which is a 2D array may cause memory corruption
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Dec 13 14:37:30 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21478
Issue ID: 21478
Summary: Setting a default value to an object field which is a
2D array may cause memory corruption
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
Trying to access `map` results in segfault.
class O {
//int[2][2] array = [[0, 0], [0, 0]]; // works fine
// also works fine:
/+
int[2][2] array;
this() { array = [0, 0]; }
+/
int[2][2] array = [0, 0]; // corrupts `map`
int[string] map;
}
void main() {
auto o = new O();
o.map["one"] = 1; // crashes
}
The bug is present in all version of DMD and not present in LDC.
--
More information about the Digitalmars-d-bugs
mailing list