Bug 3951 – [CTFE] With a fixed-size array

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-03-13T04:55:00Z
Last change time
2014-02-15T02:42:48Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-03-13T04:55:46Z
I can't invent a good name for this bug. This looks valid CTFE code, but it doesn't compile: int foo1(int n)(int[n] array) { foreach (el; array) {} return 0; } int foo2(int n)(int[n] array) { for (int i; i < n; i++) { int el = array[i]; } return 0; } int spam() { int[1] array; enum int i1 = foo1(array); enum int i2 = foo2(array); return 0; } enum int r = spam(); void main() {} Errors produced: test.d(12): Error: cannot cast int to int[] test.d(12): Error: cannot cast int to int[] test.d(12): Error: cannot cast int to int[] test.d(13): Error: cannot evaluate foo1(array) at compile time test.d(13): Error: cannot evaluate foo1(array) at compile time
Comment #1 by clugdbug — 2010-03-26T06:58:17Z
This was fixed in DMD2.042.