[Issue 4923] New: immutable module variables are modifiable in non-shared module constructors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 23 12:06:01 PDT 2010


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

           Summary: immutable module variables are modifiable in
                    non-shared module constructors
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hanazuki at gmail.com


--- Comment #0 from Kasumi Hanazuki <k.hanazuki at gmail.com> 2010-09-23 12:05:20 PDT ---
DMD v2.049 on Windows

immutable module variables, whose instances are thread-global, are modifiable
in thread-local module constructors (static this).

Following example prints different numbers on each iteration.

----

import core.thread, std.random, std.stdio;

immutable int x;

static this() {
  x = unpredictableSeed;
}

void main() {
  for(;;) {
    (new Thread({ })).start;
    Thread.sleep(1_000_000_0);
    writeln(x);
  }
}

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


More information about the Digitalmars-d-bugs mailing list