[Issue 20607] New: [shared] static constructor & co can be called as regular function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 25 03:23:38 UTC 2020


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

          Issue ID: 20607
           Summary: [shared] static constructor & co can be called as
                    regular function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: pro.mathias.lang at gmail.com

Reported by Jacob Carlborg
(https://github.com/dlang/druntime/pull/2952#issuecomment-590327741):

```
import std;

__gshared immutable int foo;
shared static this() @safe
{
    foo += 3;
    writeln("shared static this");
}

void main() @safe
{
    writefln!"foo=%s"(foo);
    _sharedStaticCtor_L4_C1();
    writefln!"foo=%s"(foo);
}
```

Breaks the type system, woohoo:
```
shared static this
foo=3
shared static this
foo=6
```

Fix on its way.

--


More information about the Digitalmars-d-bugs mailing list