Tell us your DIP1000 woes

Walter Bright newshound2 at digitalmars.com
Mon Aug 26 08:17:45 UTC 2024


I found the following inconsistency:

```
@safe ref int abc(int i) { return ghi(i); }
@trusted ref int ghi(ref int r) { return r; }

@safe int* foo(int i) { return bar(&i); } // Error: reference to local variable 
`i` assigned to non-scope parameter `p` calling `bar`
@trusted int* bar(int* p) { return p; }
```

Compiling with -dip1000 gives the error indicated. Note that it did not give an 
error for the semantically equivalent call to ghi(i).

Possible resolutions:

1. give an error for both

2. give no error for both, as @trusted implementations are the user's problem

3. disallow taking the address of a local variable in @safe code




More information about the Digitalmars-d mailing list