Issue 22801 - [REG 2.099.0-beta.1] Can't return address of return ref parameter from constructor
Summary: [REG 2.099.0-beta.1] Can't return address of return ref parameter from constr...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2022-02-21 14:40 UTC by Paul Backus
Modified: 2022-04-01 15:02 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Paul Backus 2022-02-21 14:40:27 UTC
Using -preview=dip1000, the following program compiles successfully when using DMD 2.098.1, but fails when using DMD 2.099.0-beta.1:

---
struct Wrapper
{
    int* ptr;

    this(return ref int var) @safe
    {
        this.ptr = &var;
    }
}

void main() @safe
{
    int i;
    auto w = Wrapper(i);
}
---

The error message is:

---
bug.d(7): Error: address of variable `var` assigned to `this` with longer lifetime
---
Comment 1 moonlightsentinel 2022-02-21 14:42:02 UTC
Introduced by https://github.com/dlang/dmd/pull/13577
Comment 2 Dlang Bot 2022-02-21 21:10:49 UTC
@dkorpel created dlang/dmd pull request #13699 "Fix Issue 22801 - Can't return address of return ref parameter from constructor" fixing this issue:

- Fix Issue 22801 - Can't return address of return ref parameter from constructor

https://github.com/dlang/dmd/pull/13699
Comment 3 Dlang Bot 2022-04-01 13:04:14 UTC
@dkorpel created dlang/dmd pull request #13940 "Fix Issue 22801 - [master] Can't return address of return ref parameter from constructor" fixing this issue:

- Fix Issue 22801 - Can't return address of return ref parameter from constructor

https://github.com/dlang/dmd/pull/13940
Comment 4 Dlang Bot 2022-04-01 15:02:25 UTC
dlang/dmd pull request #13940 "Fix Issue 22801 - [master] Can't return address of return ref parameter from constructor" was merged into master:

- 6fe45bc5418216449295a58e24c3b339cdc9fc6e by dkorpel:
  Fix Issue 22801 - Can't return address of return ref parameter from constructor

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