D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20675 - dip1000 improper error about copying scope parameter into allocated memory
Summary: dip1000 improper error about copying scope parameter into allocated memory
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull, safe
Depends on:
Blocks:
 
Reported: 2020-03-16 08:25 UTC by Walter Bright
Modified: 2020-03-18 00:22 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Walter Bright 2020-03-16 08:25:30 UTC
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);
}
---
Comment 1 Dlang Bot 2020-03-16 22:11:03 UTC
@aG0aep6G created dlang/dmd pull request #10929 "fix issue 20675 - dip1000 improper error about copying scope paramete…" fixing this issue:

- fix issue 20675 - dip1000 improper error about copying scope parameter into allocated memory

https://github.com/dlang/dmd/pull/10929
Comment 2 Dlang Bot 2020-03-17 08:46:09 UTC
@WalterBright created dlang/dmd pull request #10931 "fix Issue 20675 - dip1000 improper error about copying scope paramete…" fixing this issue:

- fix Issue 20675 - dip1000 improper error about copying scope parameter into allocated memory

https://github.com/dlang/dmd/pull/10931
Comment 3 Dlang Bot 2020-03-18 00:22:43 UTC
dlang/dmd pull request #10929 "fix issue 20675 - dip1000 improper error about copying scope paramete…" was merged into master:

- 4b7eccf3430b2444b2158f8ba7e2954f3919d29e by aG0aep6G:
  fix issue 20675 - dip1000 improper error about copying scope parameter into allocated memory

- b93c70082931b2c39b39819728a0f5f7afb16a83 by aG0aep6G:
  move test for issue 20675 to test/compilable/scope.d

https://github.com/dlang/dmd/pull/10929