July 06, 2021 [Issue 22105] New: std.container.array.Array.length setter creates values of init-less types | ||||
|---|---|---|---|---|
| ||||
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. -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply