www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20607] New: [shared] static constructor & co can be called as

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 puremagic.com
          Reporter: pro.mathias.lang 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.

--
Feb 24 2020