digitalmars.D.bugs - [Issue 20842] New: Structs with disabled default/copy ctors can't be
- d-bugmail puremagic.com (40/40) May 18 2020 https://issues.dlang.org/show_bug.cgi?id=20842
https://issues.dlang.org/show_bug.cgi?id=20842 Issue ID: 20842 Summary: Structs with disabled default/copy ctors can't be initialized Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: snarwin+bugzilla gmail.com The following program fails to compile with DMD v2.092.0: --- struct A { int i; disable this(ref A); } A a = { i: 123 }; struct B { int i; disable this(); } B b = { i: 123 }; --- The compiler gives the following output: --- onlineapp.d(7): Error: struct `A` has constructors, cannot use `{ initializers }`, use `A( initializers )` instead onlineapp.d(15): Error: struct `B` has constructors, cannot use `{ initializers }`, use `B( initializers )` instead --- The expected behavior is for disabled copy and default constructors to forbid only copy initialization and default initialization, respectively, rather than forbidding all initialization. --
May 18 2020