digitalmars.D.bugs - [Issue 19065] New: Struct invariant violated in safe with T.init
- d-bugmail puremagic.com (32/32) Jul 06 2018 https://issues.dlang.org/show_bug.cgi?id=19065
https://issues.dlang.org/show_bug.cgi?id=19065 Issue ID: 19065 Summary: Struct invariant violated in safe with T.init Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: default_357-line yahoo.de Consider this code: struct S { disable this(); bool b = false; this(int) { b = true; } invariant { assert(b == true); } safe ~this() { } } safe void main() { S s = S.init; } I believe the appropriate response to this is that invariant checking must be disabled on struct destructors. Struct destructors are supposed to be able to handle T.init anyways; otherwise the behavior of moveEmplace is nonsensical. This problem is, as far as I can tell, completely solved by requiring structs to be either invariant-valid or T.init at destructor call. --
Jul 06 2018