www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20675] New: dip1000 improper error about copying scope

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

          Issue ID: 20675
           Summary: dip1000 improper error about copying scope parameter
                    into allocated memory
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

Compile with -preview=dip1000:
---
struct D {
    int pos;
    char* p;
}

void test(scope ref D d)  safe {
    D[] da;

// works
    const pos = d.pos;
    da ~= D(pos, null);

// wrongly fails with
// Error: scope variable d may not be copied into allocate memory
    da ~= D(d.pos, null);
}
---

--
Mar 16