www.digitalmars.com         C & C++   DMDScript  

D - Bug: Internal error using out params

The following code generates "Internal error: ..\ztc\cgcs.c 350" when compiled:

void func2(char[] a, out char[] b)
{
b = a;
}

void func(char[] a, out char[] b)
{
int numBlocks = 1;

b.length = a.length;
//  char[] temp;
//  temp.length = numBlocks;
for(int i = 0; i < a.length; i++)
{
int start = i * numBlocks;
int end = (i + 1) * numBlocks;
func2(a[start..end], b[start..end]);
//    func2(a[start..end], temp);
//    b ~= temp;
}
}

void main()
{
static char[32] x = "12345678901234567890123456789012";
char[] y;

func(x, y);
}

Notes:
Removing the out modifier from the second parameter of func2 removes the error
(of course, func2 doesn't do what you want to either...). Uncommenting the
commented out lines in func and removing the lines immediately preceding the
commented ones provides a work around.

Using: DMD 0.72 and WinXP Home
Sep 19 2003