D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3441 - Snow Leopard: Static constructors do not work
Summary: Snow Leopard: Static constructors do not work
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All Mac OS X
: P2 major
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2009-10-25 22:43 UTC by David
Modified: 2014-04-18 09:12 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David 2009-10-25 22:43:19 UTC
import std.stdio;

class Foo {
	static int foo = 42;
	static this() {
		writefln("static constructor");
		foo = 128;
	}
}

int main() {
	writefln("main: %s", Foo.foo);
	return 0;
}

will print
"main: 42"

Static constructor never called.

(Same code works as expected on normal Leopard, this has only been seen on Snow Leopard)
Comment 1 Sean Kelly 2010-06-08 10:07:23 UTC
Verified as fixed against DMD 2.046.  I'll look at DMD1x as well to be sure.