Bug 2712 – error with passing an array slot as another array length to new

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2009-03-06T15:59:00Z
Last change time
2014-02-15T13:13:17Z
Keywords
rejects-valid
Assigned to
nobody
Creator
andrei

Comments

Comment #0 by andrei — 2009-03-06T15:59:22Z
void foo(uint n, in uint[] x) { auto y = new uint[x[n]]; } void main() { foo(new uint[10]); } Error: need size of rightmost array, not type x[n]
Comment #1 by clugdbug — 2010-01-27T02:43:25Z
This is a parsing error. Workaround: Adding () around the x[n] allows it to compile. void foo(uint n, in uint[] x) { auto y = new uint[ (x[n]) ]; } void main() { foo(7, new uint[10]); }
Comment #2 by yebblies — 2012-02-01T07:28:52Z
*** This issue has been marked as a duplicate of issue 783 ***