Bug 6566 – Length of run-time constant array

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-08-27T20:20:00Z
Last change time
2013-01-16T06:48:32Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-08-27T20:20:06Z
I think this code shows a DMD bug, I think Foo!(a3) too has to compile: template Foo(alias V) { alias int[V.length] Foo; } void main() { enum int[2] a1 = [1, 2]; Foo!(a1) b1; // OK int[2] a2 = [1, 2]; Foo!(a2) b2; // OK const int[2] a3 = [1, 2]; Foo!(a3) b3; // Error } DMD 2.055head gives: test.d(9): Error: Integer constant expression expected instead of (a3[] = [1,2]).length test.d(9): Error: Integer constant expression expected instead of (a3[] = [1,2]).length test.d(9): Error: Integer constant expression expected instead of (a3[] = [1,2]).length test.d(10): Error: template instance test.main.Foo!(a3) error instantiating test.d(9): Error: Integer constant expression expected instead of (a3[] = [1,2]).length
Comment #1 by yebblies — 2013-01-16T06:48:32Z
This seems to work now with 2.062 head Unlike the similar problem in issue 5922