Bug 20406 – Copy constructor requires default constructor

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2019-11-18T12:49:20Z
Last change time
2019-11-26T14:57:20Z
Keywords
pull
Assigned to
No Owner
Creator
Bastiaan Veelo

Comments

Comment #0 by Bastiaan — 2019-11-18T12:49:20Z
``` struct S { @disable this(); this(int) {} this(ref S other) {} } void foo(S s) {} S s = S(3); foo(s); ``` Fails compilation with a message like "Error: variable `onlineapp.main.__copytmp112` default construction is disabled for type `S`" Either removing the copy constructor or enabling the default constructor makes this work. Note that this seems to be only an issue for parameter passing, explicit initializations still work fine for the above definition of S: S s2 = s;
Comment #1 by dlang-bot — 2019-11-18T16:05:36Z
@RazvanN7 created dlang/dmd pull request #10587 "Fix Issue 20406 - Copy constructor requires default constructor" fixing this issue: - Fix Issue 20406 - Copy constructor requires default constructor https://github.com/dlang/dmd/pull/10587
Comment #2 by dlang-bot — 2019-11-26T14:57:20Z
dlang/dmd pull request #10587 "Fix Issue 20406 - Copy constructor requires default constructor" was merged into master: - f18b969ef4fe32a30ce9e2fdb8057c46c8402e20 by RazvanN7: Fix Issue 20406 - Copy constructor requires default constructor https://github.com/dlang/dmd/pull/10587