When is a dynamic array really a static array?

Paul Backus snarwin at gmail.com
Tue Dec 31 13:35:42 UTC 2019


On Tuesday, 31 December 2019 at 11:20:31 UTC, Patrick Schluter 
wrote:
> Is it really a bug?

Yes. Perhaps this example will convince you:

void foo(size_t N)(int[N] arr)
{
     arr[0] = 42;
}

void foo()(int[] arr)
{
     arr[0] = 42;
}

void main()
{
     int[16] x;
     foo(x[]);
     assert(x[0] == 42); // fails
}


More information about the Digitalmars-d mailing list