www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15622] New: Order of execution of module destructors is not

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

          Issue ID: 15622
           Summary: Order of execution of module destructors is not always
                    correct
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: yazan.dabain gmail.com

import core.stdc.stdio;
import std.parallelism;

static ~this()
{
    printf("%.*s\n", __FUNCTION__.length, __FUNCTION__.ptr);
}

shared static ~this()
{
    printf("%.*s\n", __FUNCTION__.length, __FUNCTION__.ptr);
}

void main()
{
    auto t = new TaskPool();
    t.isDaemon = true;
}

------------------

The previous code prints:

main._staticDtor1
main._sharedStaticDtor2
main._staticDtor1
main._staticDtor1
main._staticDtor1

------------------

Per http://dlang.org/spec/module.html#staticorder, shared static destructors
are defined to run after all other static destructors but in this case that is
not happening.

Original bug report: https://github.com/rejectedsoftware/vibe.d/issues/1374

--
Jan 29