Bug 783 – Cannot use an array w/ const or variable index as new[] size argument.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-01-01T12:18:00Z
Last change time
2015-06-09T05:11:58Z
Keywords
pull, rejects-valid
Assigned to
yebblies
Creator
godaves
Comments
Comment #0 by godaves — 2007-01-01T12:18:12Z
const arr = [ 1,2,3 ];
void main()
{
int[] ar2;
ar2 = new int[arr[2]]; // OK
const i = 2;
ar2 = new int[arr[i]]; // "need size of rightmost array, not type arr[i]"
size_t j = 2;
ar2 = new int[arr[j]]; // "need size of rightmost array, not type arr[j]"
}
Please remember to assign keywords to bug reports. To everybody reading this: Please look through issues you've reported and check for missing keywords.
Comment #3 by matti.niemenmaa+dbugzilla — 2010-02-18T11:38:38Z
*** Issue 3823 has been marked as a duplicate of this issue. ***