[Issue 14944] New: cannot initialize static array by static this()

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Aug 21 00:28:05 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14944

          Issue ID: 14944
           Summary: cannot initialize static array by static this()
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: yosikawa at altalk.com

Following code prints "0" using
DMD32 D Compiler v2.068.0

import std.stdio;
class Foo {
    static int[10] tbl;
    static this() {
        foreach(ref v; tbl) {
            v = 1;
        }
    }
}
void main() {
    writeln(Foo.tbl[0]);
}

--


More information about the Digitalmars-d-bugs mailing list