Bug 7099 – (D1 only) static constructor in template mixin in library not executed
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2011-12-12T15:08:00Z
Last change time
2019-11-07T08:08:45Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Robert Clipsham
Comments
Comment #0 by robert — 2011-12-12T15:08:00Z
lib.d:
----
import std.stdio;
template T() {
static this() {
writefln("A");
}
}
mixin T;
mixin(q{
static this() {
writefln("B");
}
});
static this() {
writefln("C");
}
----
test.d:
----
import lib;
void main() {
import std.stdio;
writefln("You should see ABC above.");
}
----
Compile the above files with the following:
$ dmd -lib lib.d
$ dmd test.d lib.a
The first static constructor (A) is not executed when lib.d is a library. Note that when compiled with `dmd test.d lib.d` this works as expected. Tested on Linux32 and OSX32 with dmd 2.056. This worked in previous releases, it is currently broken (not sure when it broke).
Comment #1 by clugdbug — 2011-12-19T03:36:37Z
Happens on Windows as well. This isn't a regression, it behaves the same way in D 1.040. It has never worked.
Comment #2 by robert — 2011-12-19T08:26:59Z
(In reply to comment #1)
> Happens on Windows as well. This isn't a regression, it behaves the same way in
> D 1.040. It has never worked.
I have no idea how my code used to work then. Weird.
Comment #3 by yebblies — 2014-08-31T13:55:20Z
I can't reproduce this on recent D2 (2.067 HEAD win32)
Comment #4 by razvan.nitu1305 — 2019-11-07T08:08:45Z