--- int func() { int[2] arr; int* ptr; foreach(i, ref p; arr) if(i == 0) ptr = &p; int j = *ptr; return 0; } enum e = func(); --- Error: array index 2 is out of bounds [0,0][0 .. 2] Error: CTFE internal error: illegal value __error Assertion failure: 'isCtfeValueValid(newval)' on line 6369 in file 'interpret.c'
Another illustration (foreach is in function now): --- int func() { int[2] arr; int* ptr; void f() { //Error: variable __aggr3 is used before initialization foreach(i, ref p; arr) if(i == 0) ptr = &p; } f(); int i = *ptr; return 0; } enum e = func(); ---
https://github.com/D-Programming-Language/dmd/commit/1cbd1959e41d39c812a8f4c1a17eb8535d44547a https://github.com/D-Programming-Language/dmd/commit/1394b3c55c740106555cd484697019e4a9b77109