[Issue 20842] New: Structs with disabled default/copy ctors can't be initialized
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon May 18 17:52:07 UTC 2020
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 at puremagic.com
Reporter: snarwin+bugzilla at 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.
--
More information about the Digitalmars-d-bugs
mailing list