(This might be a DMD bug) import core.time; static this() { assert(TickDuration.ticksPerSec != 0); } void main() {} The above will fail, because the core.time module constructor will not have ran when the check is performed. The assert will pass if moved inside main().
This is truly a bug somewhere, because your static ctor is not shared, yet the static ctor that sets ticspersec is shared. Shared static ctors should be run *before* non-shared ones, so this has nothing to do with dependencies. Examining the generated assembly, it's identical whether you include it in main or static this, and it does access the actual member, not some optimized-out constant. So I think it *must* be running the shared ctor *after* the unshared one. This is likely not a problem with druntime, but rather the compiler. I'll try to investigate further to see why the module is run later. Perhaps the @trusted is giving dmd fits on the shared ctor. But even so, core.time should be a dependency of the main program module, so it should still be run first.
Note that adding "shared" to the main module constructor doesn't change the situation.
Right, what I was saying though is that all shared ctors are run before all non-shared ones. So it is very surprising that a shared ctor has *not* been run before a non-shared one, regardless of dependency.
Compiles and runs with 2.059 Win32
Indeed. Seems to be fixed.