www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20726] New: safe function can modify __gshared data if

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: nobody puremagic.com
          Reporter: zorael gmail.com

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);
}
```

--
Apr 08