digitalmars.D.bugs - [Issue 14055] New: CTFE internal error with uninitialized array:
- via Digitalmars-d-bugs (43/44) Jan 26 2015 https://issues.dlang.org/show_bug.cgi?id=14055
https://issues.dlang.org/show_bug.cgi?id=14055 Issue ID: 14055 Summary: CTFE internal error with uninitialized array: Assertion failure: '0' on line 318 in file 'interpret.c' Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: nairolf online.de DMD 2.066.1 / Windows 7 64-bit --- struct S { static returnsFoo() { uint[1] foo = void; return foo; } static enum fooEnum = returnsFoo(); // Line 9 static uint[1] fooArray = fooEnum[]; } ---dmd bug.d -mainbug.d(9): Error: uninitialized variable 'foo' cannot be returned from CTFE Error: CTFE internal error: ErrorExp in bug.d(9) Assertion failure: '0' on line 318 in file 'interpret.c' abnormal program termination --- I found 3 ways to influence the error: - Remove "uint[1]" from line 10: Internal error disappears, compilation error (rightfully) stays - Replace "enum" with "immutable" (or const) in line 9: ErrorExp now in line 5 instead of 9 - Replace all static arrays with dynamic arrays ("[1]" -> "[]"): Internal error disappears, compilation error message changes (more detailed) The line with assert(0) in interpret.c: https://github.com/D-Programming-Language/dmd/blob/v2.066.1/src/interpret.c#L318 --
Jan 26 2015