[Issue 17213] New: [REG2.072] take address of ref return value @safe

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Feb 20 12:49:05 PST 2017


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

          Issue ID: 17213
           Summary: [REG2.072] take address of ref return value @safe
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: jbc.engelen at gmail.com

This code compiles with 2.071, but not with 2.072 nor 2.073:
```
    struct S {
        int i;

        auto ref foo() @safe {
            return i;
        }

        auto bar() @safe {
            return &foo(); // <-- Error
        }
    }

    void main() {
        auto s = S();
        s.bar();
    }
```
The error is: "cannot take address of ref return of this.foo() in @safe
function bar".

Is this a compiler regression, or is it a bug in the D code?

--


More information about the Digitalmars-d-bugs mailing list