@safe function with __gshared as default parameter value

Anonymouse zorael at gmail.com
Wed Apr 8 16:53:05 UTC 2020


```
import std.stdio;

@safe:

__gshared int gshared = 42;

void foo(int i = gshared)
{
     writeln(i);
}

void main()
{
     foo();
}
```

This currently works; `foo` is `@safe` and prints the value of 
`gshared`. Changing the call in main to `foo(gshared)` errors.

Should it work, and can I expect it to keep working?


More information about the Digitalmars-d-learn mailing list