www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Returning the address of a reference return value in safe code -

reply Johan Engelen <j j.nl> writes:
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
Feb 20 2017
next sibling parent reply Jack Stouffer <jack jackstouffer.com> writes:
On Monday, 20 February 2017 at 20:49:43 UTC, Johan Engelen wrote:
 ...
Yeah, this is another regression caused by DIP1000. Christ.
Feb 20 2017
parent reply Jack Stouffer <jack jackstouffer.com> writes:
On Monday, 20 February 2017 at 20:54:31 UTC, Jack Stouffer wrote:
 On Monday, 20 February 2017 at 20:49:43 UTC, Johan Engelen 
 wrote:
 ...
Yeah, this is another regression caused by DIP1000. Christ.
For the record, the current list of regressions caused by DIP1000 https://issues.dlang.org/show_bug.cgi?id=17213 https://issues.dlang.org/show_bug.cgi?id=17188 https://issues.dlang.org/show_bug.cgi?id=17123 https://issues.dlang.org/show_bug.cgi?id=17117
Feb 20 2017
parent Dominikus Dittes Scherkl <Dominikus.Scherkl continental-corporation.com> writes:
On Monday, 20 February 2017 at 21:05:17 UTC, Jack Stouffer wrote:
 On Monday, 20 February 2017 at 20:54:31 UTC, Jack Stouffer 
 wrote:
 On Monday, 20 February 2017 at 20:49:43 UTC, Johan Engelen 
 wrote:
 ...
Yeah, this is another regression caused by DIP1000. Christ.
For the record, the current list of regressions caused by DIP1000 https://issues.dlang.org/show_bug.cgi?id=17213 https://issues.dlang.org/show_bug.cgi?id=17188 https://issues.dlang.org/show_bug.cgi?id=17123 https://issues.dlang.org/show_bug.cgi?id=17117
17117 and 17123 are already fixed on HEAD, no? So only two regressions remaining - I hope DIP1000 can be used to build new container libraries soon.
Feb 21 2017
prev sibling parent Kagamin <spam here.lot> writes:
On Monday, 20 February 2017 at 20:49:43 UTC, Johan Engelen wrote:
 The error is: "cannot take address of ref return of this.foo() 
 in  safe function bar".
Maybe a bugfix in safety system? Should it go through deprecation process?
Feb 22 2017