Possible problem with new array

Gide Nwawudu gide at btinternet.com
Fri May 2 03:06:16 PDT 2008


On Thu, 01 May 2008 20:50:05 -0400, bearophile
<bearophileHUGS at lycos.com> wrote:

>
>The following code:
>
>
>
>void main() {
>
>  int[1] a = [10];
>
>  int i;
>
>  int[] b = new int[a[i]];
>
>}
>
>
>
>Generates this error (DMD V.1.028):
>
>need size of rightmost array, not type a[i]
>
>
>
>Is this a DMD bug or an error of mine?

It doesn't compile on D2.013 either, looks like a bug. The workaround
is to put a[i] in parenthesis.

>  int[] b = new int[a[i]];
int[] b = new int[(a[i])];

Gide


More information about the Digitalmars-d-learn mailing list