https://issues.dlang.org/show_bug.cgi?id=12764
Issue ID: 12764
Summary: Disabled struct default construction circumvented when
field is written to
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: accepts-invalid
Severity: major
Priority: P1
Component: DMD
Assignee: [email protected]
Reporter: [email protected]
-----
struct S
{
@disable this();
this(string) { }
int f;
}
class C
{
this(int)
{
s.f = 1; // circumvents default ctor!
}
S s;
}
void main() { }
-----
If we comment out writing to 'f' we get:
test.d(11): Error: constructor test.C.this field s must be initialized in
constructor
This should always be emitted unless we explicitly call "s = S(...)" or "s =
S.init".
--