When is a dynamic array really a static array?

Temtaime temtaime at gmail.com
Tue Dec 31 17:24:38 UTC 2019


On Tuesday, 31 December 2019 at 13:35:42 UTC, Paul Backus wrote:
> 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
> }

void foo(size_t N)(int[N] arr) does nothing. I doubt this is a 
bug too.


More information about the Digitalmars-d mailing list