www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20908] New: -preview=nosharedaccess requires

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

          Issue ID: 20908
           Summary: -preview=nosharedaccess requires zero-initializion for
                    aggregates
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: moonlightsentinel disroot.org

-preview=nosharedaccess raises an error for aggregates that are not
zero-initialized.

=============================================
struct S
{
    int i = 2;
}

interface I
{
    void foo();
}

class C : I
{
    int i;
    override void foo() {}
}

union U
{
    int i = 1;
    bool b;
}

void main()
{
    shared int num;
    shared S s;
    shared I i;
    shared C c;
    shared U u;
}
=============================================
shared_init.d(1): Error: direct access to shared S is not allowed, see
core.atomic
shared_init.d(17): Error: direct access to shared U is not allowed, see
core.atomic

--
Jun 08