D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20682 - [DIP1000] wrong error: scope variable may not be copied into allocated memory
Summary: [DIP1000] wrong error: scope variable may not be copied 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, rejects-valid, safe
Depends on:
Blocks:
 
Reported: 2020-03-17 16:44 UTC by ag0aep6g
Modified: 2020-03-19 06:59 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 ag0aep6g 2020-03-17 16:44:37 UTC
Similar to issue 20675.

----
struct D
{
    int pos;
    char* p;
}

int f1(return scope ref D d) @safe
{
    return d.pos;
}

ref int f2(return scope ref D d) @safe
{
    return d.pos;
}

void test(scope ref D d) @safe
{
    int[] da;
    da ~= f1(d);
    da ~= f2(d);
}
----
Comment 1 Dlang Bot 2020-03-17 16:56:22 UTC
@aG0aep6G created dlang/dmd pull request #10935 "fix issue 20682 - [DIP1000] wrong error: scope variable may not be co…" fixing this issue:

- fix issue 20682 - [DIP1000] wrong error: scope variable may not be copied into allocated memory

https://github.com/dlang/dmd/pull/10935
Comment 2 Dlang Bot 2020-03-19 06:59:19 UTC
dlang/dmd pull request #10935 "fix issue 20682 - [DIP1000] wrong error: scope variable may not be co…" was merged into master:

- 84044afae2b3ebc23088dd1d201edba1b044559c by aG0aep6G:
  fix issue 20682 - [DIP1000] wrong error: scope variable may not be copied into allocated memory

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