D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20940 - DMD silently ignores struct copy constructor if one of the element struct has postblit
Summary: DMD silently ignores struct copy constructor if one of the element struct has...
Status: RESOLVED DUPLICATE of issue 20714
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 critical
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-17 03:21 UTC by Puneet Goel
Modified: 2020-06-17 03:59 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Puneet Goel 2020-06-17 03:21:12 UTC
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 RazvanN 2020-06-17 03:59:09 UTC

*** This issue has been marked as a duplicate of issue 20714 ***