Bug 20940 – DMD silently ignores struct copy constructor if one of the element struct has postblit
Status
RESOLVED
Resolution
DUPLICATE
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-06-17T03:21:12Z
Last change time
2020-06-17T03:59:09Z
Assigned to
No Owner
Creator
Puneet Goel
Comments
Comment #0 by puneet — 2020-06-17T03:21:12Z
Copy constructor for Bar and Frop are silently ignored. When codebase is large with Bar having a significant number of elements, it becomes very confusing why copy constructor of Bar and Frop are getting ignored. Perhaps Foo could as well be imported from a library module.
////
import std.stdio;
struct Frop {
this (ref inout(Frop) frop) {
writeln("Frop copy constructor");
}
}
struct Foo {
this(this) {
writeln("Foo postblit constructor");
}
}
struct Bar {
Foo foo;
Frop frop;
this (ref inout(Bar) bar) {
writeln("Bar copy constructor");
foo = bar.foo;
frop = bar.frop;
}
}
void main() {
Bar bar;
Bar bar2 = bar;
}
Comment #1 by razvan.nitu1305 — 2020-06-17T03:59:09Z
*** This issue has been marked as a duplicate of issue 20714 ***