Bug 2562 – foreach over uninitialized array fails in CTFE
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2009-01-07T08:38:00Z
Last change time
2014-03-01T00:36:14Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2009-01-07T08:38:29Z
int foo()
{
int [] xxx;
foreach(q; xxx) {}
return 1;
}
static assert(foo());
----
bug.d(8): Error: cannot evaluate foo() at compile time
bug.d(8): static assert (foo()) is not evaluatable at compile
time
Workarounds: (1) Replace the foreach with for:
for (int q=0; q<xxx.length; ++q) {}
(2) Initialize the array
int [] xxx = [];
This is NOT the same as issue 1375, which appears to be fixed.