D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7611 - static this() in template is not executed in .lib
Summary: static this() in template is not executed in .lib
Status: RESOLVED DUPLICATE of issue 7754
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-29 08:08 UTC by sweatygarlic
Modified: 2012-03-23 23:52 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description sweatygarlic 2012-02-29 08:08:17 UTC
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 Kenji Hara 2012-03-23 23:52:46 UTC

*** This issue has been marked as a duplicate of issue 7754 ***