Bug 7611 – static this() in template is not executed in .lib
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-02-29T08:08:00Z
Last change time
2012-03-23T23:52:46Z
Assigned to
nobody
Creator
sweatygarlic
Comments
Comment #0 by sweatygarlic — 2012-02-29T08:08:17Z
The situation is like this.(dmd 2.058)
====================
libtest.d
--------------------
template typestring( T ) {
string typestring = T.stringof;
static this() {
assert(0);
}
}
alias typestring!int ti;
--------------------
>dmd -lib -H libtest.d
test.d
--------------------
import std.stdio;
import libtest; // <- libtest.di is imported.
pragma( lib, "libtest.lib" );
alias typestring!uint tui;
//mixin typestring!uint tui; // it is no matter, alias or mixin.
void main() {
//writeln( ti); // <- uncomment to Assertion failure
writeln( tui ); // <- with no Assertion failure, "uint" is printed.
}
--------------------
>dmd test.d
>./test.exe
>uint
====================
When libtest.d is imported, or when I write the body code of the static this() to libtest.di, assertion failure occur.
Comment #1 by k.hara.pg — 2012-03-23T23:52:46Z
*** This issue has been marked as a duplicate of issue 7754 ***