[Issue 22510] New: Structs with copy constructor can not be heap allocated with default constructor
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Nov 14 11:12:10 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22510
Issue ID: 22510
Summary: Structs with copy constructor can not be heap
allocated with default constructor
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: omerfirmak at gmail.com
import std;
struct S
{
int b;
@disable this(this);
this (scope ref inout S) inout
{
this.b = b;
}
}
void main()
{
auto scoped_s = S(4);
auto heap_s = new S(42);
}
-----------------------------------
`auto heap_s = new S(42)` line fails with the following error;
onlineapp.d(17): Error: copy constructor `onlineapp.S.this(ref inout(S)
_param_0) inout` is not callable using argument types `(int)`
onlineapp.d(17): cannot pass rvalue argument `42` of type `int` to
parameter `ref inout(S) _param_0`
--
More information about the Digitalmars-d-bugs
mailing list