[Issue 15622] New: Order of execution of module destructors is not always correct

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jan 29 03:50:30 PST 2016


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 at puremagic.com
          Reporter: yazan.dabain at 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

--


More information about the Digitalmars-d-bugs mailing list