[Issue 14944] cannot initialize static array by static this()
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Aug 21 01:46:38 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14944
bb.temp at gmx.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bb.temp at gmx.com
--- Comment #1 from bb.temp at gmx.com ---
The problem is more subtle than suggested by the summary. Actually the problem
is the **ref** in foreach().
Initialization of the array succeeds if you use another form of for loop, e.g
---
import std.stdio;
class Foo {
static int[10] tbl;
static this() {
foreach(i; 0 .. tbl.length) {
tbl[i] = 1;
}
}
}
void main() {
writeln(Foo.tbl[0]); // 1
}
---
--
More information about the Digitalmars-d-bugs
mailing list