[Issue 23709] New: Cannot use synchronized on shared class with -preview=nosharedaccess

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 15 09:22:40 UTC 2023


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

          Issue ID: 23709
           Summary: Cannot use synchronized on shared class with
                    -preview=nosharedaccess
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: atila.neves at gmail.com

class Class {}
void main() {
    synchronized(new shared Class) {}
}

% clear && dmd -g -debug -preview=nosharedaccess d.d && ./d
% d.d(3): Error: direct access to shared `new shared(Class)` is not allowed,
see `core.atomic`


This means that it's not actually possible to synchronize on any given mutex.

--


More information about the Digitalmars-d-bugs mailing list