https://issues.dlang.org/show_bug.cgi?id=20726

          Issue ID: 20726
           Summary: @safe function can modify __gshared data if passed as
                    ref parameter default value
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

Manjaro/Arch x86_64, dmd v2.091.0 but also all dmd compilers v2.060 up to
current on run.dlang.io.

This passes and __gshared `gshared` is modified by `foo`.


```
__gshared int gshared = 42;

void foo(ref int i = gshared) @safe
{
    ++i;
}

void main()
{
    assert(gshared == 42);
    foo();
    assert(gshared == 43);
}
```

--

Reply via email to