Bug 12764 – Disabled struct default construction circumvented when field is written to

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-05-18T15:44:40Z
Last change time
2018-05-26T13:05:38Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Andrej Mitrovic

Comments

Comment #0 by andrej.mitrovich — 2014-05-18T15:44:40Z
----- 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".
Comment #1 by razvan.nitu1305 — 2018-04-22T11:44:55Z
Comment #2 by github-bugzilla — 2018-05-26T13:05:37Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/0e25d4ddc88d1262537dad33656dabf9fb750ea6 Fix Issue 12764 - Disabled struct default construction circumvented when field is written to https://github.com/dlang/dmd/commit/1805141e3848adbf57edac8a0c0e80e99c7ee405 Merge pull request #8201 from RazvanN7/Issue_12764 Fix Issue 12764 - Disabled struct default construction circumvented when field is written to merged-on-behalf-of: Razvan Nitu <[email protected]>