Bug 6137 – [CTFE] Foreach on semantically wrong initialized array crashes the compiler

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-06-09T16:10:00Z
Last change time
2011-06-10T12:14:53Z
Assigned to
nobody
Creator
timon.gehr

Comments

Comment #0 by timon.gehr — 2011-06-09T16:10:04Z
The following (invalid) code segfaults DMD (2.053). enum qux = foo(); int[] bar = [[]*[[]<>[]]*[]]; // can be anything that is not an int[] int foo(){ foreach(t;bar){} return 0; } void main(){} It does not matter what the initializer of bar is at long as it is not an int[]. The segmentation fault still occurs if bar is set to immutable. Compilation output: Error: static variable bar cannot be read at compile time Segmentation fault
Comment #1 by timon.gehr — 2011-06-10T02:33:49Z
This bug is introduced with DMD 2.053.
Comment #2 by clugdbug — 2011-06-10T12:14:53Z
Fixed in git master, as part of the fixes to CTFE references. https://github.com/D-Programming-Language/dmd/pull/69