[Issue 20695] New: Copy constructor disable default struct constructor
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 23 08:53:52 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20695
Issue ID: 20695
Summary: Copy constructor disable default struct constructor
Product: D
Version: D2
Hardware: x86
OS: Mac OS X
Status: NEW
Keywords: C++, rejects-valid
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: pro.mathias.lang at gmail.com
```
struct Bar
{
this(const ref Bar o) {}
string a;
uint b;
}
void main ()
{
// foo.d(11): Error: struct Bar has constructors, cannot use { initializers
}, use Bar( initializers ) instead
Bar b = { a: "Hello", b: 42 };
// foo.d(12): Error: copy constructor foo.Bar.this(ref const(Bar) o) is not
callable using argument types (string\
, int)
// foo.d(12): cannot pass rvalue argument "Hello" of type string to
parameter ref const(Bar) o
Bar c = Bar("Hello", 42);
}
```
Expected result: This should compile. It should also work if the constructor is
`@disable`d.
--
More information about the Digitalmars-d-bugs
mailing list