www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17213] New: [REG2.072] take address of ref return value safe

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 puremagic.com
          Reporter: jbc.engelen 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?

--
Feb 20 2017