digitalmars.D.bugs - [Issue 17476] New: Static fields don't seem to be reliably
- via Digitalmars-d-bugs (49/49) Jun 07 2017 https://issues.dlang.org/show_bug.cgi?id=17476
https://issues.dlang.org/show_bug.cgi?id=17476 Issue ID: 17476 Summary: Static fields don't seem to be reliably initialized when using parallel() Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: andrej.mitrovich gmail.com ``` import std.stdio; import std.parallelism; struct Params { static string path = "/some/string/initializer"; } void main() { Params.path = "foobar"; foreach (_; parallel([1, 2, 3, 4])) { writefln("%s", Params.path); } } ``` Run this a few times, and each time the results will be wildly different: ``` ~/dev/d test.d * $ dmd -run test.d foobar /some/string/initializer /some/string/initializer /some/string/initializer ~/dev/d test.d * $ dmd -run test.d /some/string/initializer foobar /some/string/initializer /some/string/initializer ~/dev/d test.d * $ dmd -run test.d foobar foobar /some/string/initializer /some/string/initializer ``` --
Jun 07 2017