digitalmars.D.bugs - [Issue 22487] New: Array!T.init.data crashes
- d-bugmail puremagic.com (29/29) Nov 07 2021 https://issues.dlang.org/show_bug.cgi?id=22487
https://issues.dlang.org/show_bug.cgi?id=22487 Issue ID: 22487 Summary: Array!T.init.data crashes Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: timon.gehr gmx.ch CC: dandrei279 gmail.com, maxhaton gmail.com The fix for issue 21100 is buggy, the following code crashes: --- void main(){ import std.container; Array!int a; foreach(i;a.data){} } --- core.exception.AssertError std/typecons.d(6644): Attempted to access an uninitialized payload. --- It should check whether the data is initialized, like most other members of Array!T do. If the data is not initialized, it should return an empty dynamic array. --
Nov 07 2021