Bug 21478 – Setting a default value to an object field which is a 2D array may cause memory corruption

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-12-13T14:37:30Z
Last change time
2021-03-22T10:39:26Z
Keywords
backend, ice
Assigned to
No Owner
Creator
Georgy Markov

Comments

Comment #0 by ogion.art — 2020-12-13T14:37:30Z
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.
Comment #1 by ogion.art — 2021-03-22T10:39:26Z
DMD 2.096 seems to have fixed this.