[Issue 20195] New: -preview=nosharedaccess has some access problems

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Sep 8 03:14:45 UTC 2019


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

          Issue ID: 20195
           Summary: -preview=nosharedaccess has some access problems
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: turkeyman at gmail.com

I'm trying to build some tooling using `-preview=nosharedaccess`, but there are
some edges that are wrong.

Try and compile this code:

void test()
{
  // shared locals (or struct members) should be able to be initialised:
  shared int x;
  // error : direct access to shared `x` is not allowed, see `core.atomic`

  ref shared(int) fun()
  {
    static shared(int) val = void; // init `void` to silence the error noted
above

    // return by reference:
    return val;
    // error : direct access to shared `val` is not allowed, see `core.atomic`
  }

  ref shared(int) fun2()
  {
    static shared(int)* val;

    // transfer pointer to reference:
    return *val;
    // error : direct access to shared `*val` is not allowed, see `core.atomic`
  }
}


I think shared things need to be able to initialise, because they can't
possibly have been shared around before they were constructed.

There just seems to be some problems interacting with ref; I suspect every
interaction with ref will yield the same issues.

--


More information about the Digitalmars-d-bugs mailing list