Returning the address of a reference return value in @safe code - 2.072 regression?
Johan Engelen via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Feb 20 12:49:43 PST 2017
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?
https://issues.dlang.org/show_bug.cgi?id=17213
Thanks,
Johan
More information about the Digitalmars-d-learn
mailing list