Bug 1315 – CTFE doesn't default initialise arrays of structs

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-07-05T10:43:00Z
Last change time
2014-02-16T15:23:35Z
Assigned to
bugzilla
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2007-07-05T10:43:22Z
Seems as though struct arrays aren't default initialised inside CTFE. CTFE disallows concatenation to an unitialised struct array, also can't get the length. Workaround is easy - just initialise the array to []. ----------- struct S { int a; } int func() { /* This is OK int [] q; q ~=4; */ S [] s; // makes the next lines fail. (but S[] s = []; compiles). s ~= S(7); // fails return s.length; // this fails too } void main() { const int x = func(); }
Comment #1 by bugzilla — 2007-09-28T22:06:39Z
Fixed dmd 1.021 and 2.004