Bug 24705 – Arguments of synchronized method are unintentionally treated as shared with -preview=nosharedaccess

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-08-16T07:31:54Z
Last change time
2024-08-16T22:37:32Z
Keywords
pull
Assigned to
No Owner
Creator
Kazuki Komatsu

Comments

Comment #0 by komatsu.kazuki.op — 2024-08-16T07:31:54Z
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() {} ```
Comment #1 by komatsu.kazuki.op — 2024-08-16T07:36:29Z
The latest (nightly) compiler version I tried is shown below, and this version also outputs the same error. ```sh $ dmd --version DMD64 D Compiler v2.110.0-beta.1 Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved written by Walter Bright ```
Comment #2 by dlang-bot — 2024-08-16T14:47:54Z
@ntrel created dlang/dmd pull request #16788 "Fix Bugzilla 24705 - Arguments of synchronized method are wrongly sha…" fixing this issue: - Fix Bugzilla 24705 - Arguments of synchronized method are wrongly shared with -preview=nosharedaccess https://github.com/dlang/dmd/pull/16788
Comment #3 by dlang-bot — 2024-08-16T22:37:32Z
dlang/dmd pull request #16788 "Fix Bugzilla 24705 - Arguments of synchronized method are wrongly sha…" was merged into master: - fc48f5130f19ff6a1f0bb79d81c8b1c4c0ee16a9 by Nick Treleaven: Fix Bugzilla 24705 - Arguments of synchronized method are wrongly shared with -preview=nosharedaccess https://github.com/dlang/dmd/pull/16788