www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16131] New: A struct is being copied unnecessarily when


          Issue ID: 16131
           Summary: A struct is being copied unnecessarily when
           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

Even when the struct disallows copying, it is being temporarily created and
copied. This reproduces on both dmd and ldc2.

Reproducing example:

struct Foo {
     disable this(this);
    this(out Foo *x) { x = &this; }

void main() {
    Foo *x;
    auto a = Foo(x);
    assert(x == &a); // OK
    Foo b;
    b = Foo(x);
    assert(x == &b); // FAILS

Jun 06 2016