[Issue 23639] New: Casting to shared not allowed with -preview=nosharedaccess

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 18 12:16:27 UTC 2023


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

          Issue ID: 23639
           Summary: Casting to shared not allowed with
                    -preview=nosharedaccess
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: razvan.nitu1305 at gmail.com

Consider the following code:

class T {}

shared(T) allocClassMem()
{
    void *p;
    // assume p is allocated here 
    return cast(shared(T))p;
}

This yields:  Error: direct access to shared `cast(shared(T))p` is not allowed,
see `core.atomic`

How is one supposed to allocate shared memory if casting is not allowed?

--


More information about the Digitalmars-d-bugs mailing list