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
Comment #1 by k.hara.pg — 2015-01-27T13:29:36Z
Comment #2 by github-bugzilla — 2015-01-30T23:21:10Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7099d9a5512f3cf2208b7c0bd3ff3590bde5382e fix Issue 14055 - CTFE internal error with uninitialized array: Assertion failure: '0' on line 318 in file 'interpret.c' scrubArray() should propagate ErrorExp if CTFE returns uninitialized value. https://github.com/D-Programming-Language/dmd/commit/f687cd1522c941f5093cf5341300fc81b0c81868 Merge pull request #4348 from 9rnsr/fix14055 Issue 14055 - CTFE internal error with uninitialized array: Assertion failure: '0' on line 318 in file 'interpret.c'