www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21317] New: Copy constructor defined but blitting still occurs


          Issue ID: 21317
           Summary: Copy constructor defined but blitting still occurs
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: eyal weka.io

implicit blitting, despite the DIP[1] claiming: "When a copy constructor is
defined for a struct, all implicit blitting is disabled for that struct".

  import std.stdio;

  struct S {
      this(int x) { writefln("%s", &this); }
      ~this() { writefln("%s", &this); }

      this(scope ref return S) {}

  unittest {
      auto f() { return S(1); }
      auto x = f();

Still does blit/copy, silently.

[1] https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1018.md

Oct 16 2020