http://d.puremagic.com/issues/show_bug.cgi?id=6114

           Summary: immutable class variable not properly initialized when
                    the constructor initializing it is non-shared
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: jmdavisp...@gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisp...@gmx.com> 2011-06-05 23:31:52 
PDT ---
This is related to bug# 6113. If you go into std.datetime and change the static
constructors which initialize UTC._utc or LocalTime._localTime (search for
"_utc =" or "_localTime =" - minus the quotes - to find them quickly), then
this code will fail:

import std.datetime;

shared static this()
{
  assert(UTC() !is null);
  assert(LocalTime() !is null);
}

void main()
{}


As long as those static constructors are shared, then this code is fine. But if
they're not shared, then the assertions fail. I believe that this is related to
bug# 4923 and the fact that immutable global variables and immutable static
variables are implicitly shared. I really think that the language should be
altered such that it be an error to attempt to initialize an immutable global
variable or immutable static variable in a non-shared constructor. Since,
they're implicitly shared, it doesn't make sense to initialize them in a
thread-local manner anyway. And it's obviously causing problems as-is.

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

Reply via email to