[Issue 13706] New: 76 duplicate static dtors emitted and counting
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Nov 10 02:39:49 PST 2014
https://issues.dlang.org/show_bug.cgi?id=13706
Issue ID: 13706
Summary: 76 duplicate static dtors emitted and counting
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: wrong-code
Severity: major
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: Marco.Leise at gmx.de
When using separate compilation, DMD emits and calls many duplicate static
dtors. In one larger code base I found the counter at 76 while debugging an
issue. Here is a reduced test case that creates only one duplicate:
----------8<----------
module main;
import a, b;
void main()
{
A a;
B b;
}
---------->8----------
----------8<----------
module a;
import res;
struct A { Block!() field; }
---------->8----------
----------8<----------
module b;
import std.typecons, res;
struct B { Block!() field; }
---------->8----------
----------8<----------
module res;
struct Block()
{
import core.stdc.stdio;
shared static ~this() { debug printf ("struct Block shared static dtor
%s\n", __FUNCTION__.ptr); }
static ~this() { debug printf ("struct Block static dtor
%s\n", __FUNCTION__.ptr); }
}
---------->8----------
This prints on DMD 2.066.1 and 2.065.0:
struct Block static dtor res.Block!().Block._staticDtor6
struct Block static dtor res.Block!().Block._staticDtor4
struct Block shared static dtor res.Block!().Block._sharedStaticDtor5
struct Block shared static dtor res.Block!().Block._sharedStaticDtor3
On DMD 2.064.2 the output was:
struct Block static dtor res.Block!().Block._staticDtor11
struct Block static dtor res.Block!().Block._staticDtor4
struct Block shared static dtor res.Block!().Block._sharedStaticDtor10
struct Block shared static dtor res.Block!().Block._sharedStaticDtor3
Tagged as wrong code, like when a common dtor would be called twice by the
runtime.
P.S.: I also wonder what the static dtors 1 and 2 are created for. I often get
runtime errors about circular dependencies of modules with static constructors,
but cannot see any in the respective modules.
--
More information about the Digitalmars-d-bugs
mailing list