[Issue 20406] New: Copy constructor requires default constructor
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 18 12:49:20 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20406
Issue ID: 20406
Summary: Copy constructor requires default constructor
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: Bastiaan at Veelo.net
```
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;
--
More information about the Digitalmars-d-bugs
mailing list