www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20940] New: DMD silently ignores struct copy constructor if

https://issues.dlang.org/show_bug.cgi?id=20940

          Issue ID: 20940
           Summary: DMD silently ignores struct copy constructor if one of
                    the element struct has postblit
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: puneet coverify.org

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;
}

--
Jun 16