Bug 14055 – CTFE internal error with uninitialized array: Assertion failure: '0' on line 318 in file 'interpret.c'
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-27T01:21:00Z
Last change time
2015-01-30T23:21:10Z
Keywords
CTFE, ice
Assigned to
nobody
Creator
nairolf
Comments
Comment #0 by nairolf — 2015-01-27T01:21:26Z
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 -main
bug.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