[Issue 22801] New: [REG 2.099.0-beta.1] Can't return address of return ref parameter from constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 21 14:40:27 UTC 2022


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

          Issue ID: 22801
           Summary: [REG 2.099.0-beta.1] Can't return address of return
                    ref parameter from constructor
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: snarwin+bugzilla at gmail.com

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
---

--


More information about the Digitalmars-d-bugs mailing list