[Issue 20365] New: Copy constructor not invoked on static arrays of structs but the postblit works
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 6 22:23:52 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20365
Issue ID: 20365
Summary: Copy constructor not invoked on static arrays of
structs but the postblit works
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: sahmi.soulaimane at gmail.com
Copy constructor case: https://run.dlang.io/is/xzVWOi
```
extern(C) void puts(const char*);
struct S
{
long[3] a;
this(ref typeof(this)) { puts("CC"); }
}
void main()
{
S[4] a;
auto b = a;
}
```
Prints nothing. Expected to print "CC" four times.
Postblit case: https://run.dlang.io/is/OX4O8I
```
extern(C) void puts(const char*);
struct S
{
long[3] a;
this(this) { puts("PB"); }
}
void main()
{
S[4] a;
auto b = a;
}
```
prints "PB" four times as expected.
--
More information about the Digitalmars-d-bugs
mailing list