digitalmars.D.bugs - [Issue 22105] New: std.container.array.Array.length setter creates
- d-bugmail puremagic.com (34/34) Jul 05 2021 https://issues.dlang.org/show_bug.cgi?id=22105
https://issues.dlang.org/show_bug.cgi?id=22105 Issue ID: 22105 Summary: std.container.array.Array.length setter creates values of init-less types Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: accepts-invalid Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: dlang-bugzilla thecybershadow.net //////////////////// test.d /////////////////// import std.container.array; struct NonZero { private int n; disable this(); this(int n) { assert(n != 0); this.n = n; } invariant { assert(n != 0); } property int value() const { return n; } } void main() { Array!NonZero a; a.length = 5; assert(a[0].n != 0); } /////////////////////////////////////////////// This should not be allowed. --
Jul 05 2021