www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24705] New: Arguments of synchronized method are

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

          Issue ID: 24705
           Summary: Arguments of synchronized method are unintentionally
                    treated as shared with -preview=nosharedaccess
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: komatsu.kazuki.op tut.jp

The following code should compile without error even with
-preview=nosharedaccess, but in fact the argument `int n` is treated as shared,
resulting in an error.
I have confirmed that all dmd compilers from version 2.088.1 to 2.100.2 (and
also in the current nightly) have the same bug.


```d
// $ dmd test.d -preview=nosharedaccess
class MyClass
{
    synchronized void foo(int n)
    {
        // Error: direct access to shared `n` is not allowed, see `core.atomic`
        int a = n;
    }
}

void main() {}
```

--
Aug 16