Re: @safe function with __gshared as default parameter value

2020-04-08 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 19:53:03 UTC, jmh530 wrote: Well that definitely shouldn't happen. I would file a bug report. Filed as https://issues.dlang.org/show_bug.cgi?id=20726

Re: @safe function with __gshared as default parameter value

2020-04-08 Thread data pulverizer via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 19:29:17 UTC, Anonymouse wrote: ``` __gshared int gshared = 42; void foo(ref int i = gshared) @safe { ++i; } void main() { assert(gshared == 42); foo(); assert(gshared == 43); } ``` Dude, you just broke `@safe`! Lol!

Re: @safe function with __gshared as default parameter value

2020-04-08 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 19:29:17 UTC, Anonymouse wrote: [snip] It works with `ref int` too. ``` __gshared int gshared = 42; void foo(ref int i = gshared) @safe { ++i; } void main() { assert(gshared == 42); foo(); assert(gshared == 43); } ``` Well that definitely

Re: @safe function with __gshared as default parameter value

2020-04-08 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 19:22:11 UTC, jmh530 wrote: On Wednesday, 8 April 2020 at 18:50:16 UTC, data pulverizer wrote: On Wednesday, 8 April 2020 at 16:53:05 UTC, Anonymouse wrote: ``` import std.stdio; @safe: __gshared int gshared = 42; void foo(int i = gshared) { writeln(i); }

Re: @safe function with __gshared as default parameter value

2020-04-08 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 18:50:16 UTC, data pulverizer wrote: On Wednesday, 8 April 2020 at 16:53:05 UTC, Anonymouse wrote: ``` import std.stdio; @safe: __gshared int gshared = 42; void foo(int i = gshared) { writeln(i); } void main() { foo(); } ``` This currently works; `foo`

Re: @safe function with __gshared as default parameter value

2020-04-08 Thread data pulverizer via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 16:53:05 UTC, Anonymouse wrote: ``` 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