Summary: foreach over uninitialized array fails in CTFE
           Product: D
           Version: 1.039
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

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

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.


Reply via email to