Thread overview
[Issue 6631] New: core.time module constructor runs AFTER main program's module constructor
Sep 09, 2011
Vladimir Panteleev
Sep 09, 2011
Vladimir Panteleev
Apr 27, 2012
SomeDude
Apr 27, 2012
Vladimir Panteleev
September 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6631

           Summary: core.time module constructor runs AFTER main program's
                    module constructor
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody@puremagic.com
        ReportedBy: thecybershadow@gmail.com


--- Comment #0 from Vladimir Panteleev <thecybershadow@gmail.com> 2011-09-08 17:30:31 PDT ---
(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().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6631



--- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> 2011-09-09 05:27:48 PDT ---
Note that adding "shared" to the main module constructor doesn't change the situation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6631



--- Comment #3 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-09-09 08:05:25 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6631


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #4 from SomeDude <lovelydear@mailmetrash.com> 2012-04-27 14:37:45 PDT ---
Compiles and runs with 2.059 Win32

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6631


Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #5 from Vladimir Panteleev <thecybershadow@gmail.com> 2012-04-27 14:42:25 PDT ---
Indeed. Seems to be fixed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------