Is the following compiler behavior consistent with language specification?

import std.stdio;

void main()
{
    int a[][] = [[1,2,3]];
    foreach(x; a)
    {
        x[0] = 0;
        x ~= 4;
    }
    writeln(a);
}

I understand why thw program could output [1,2,3] (like in C++ without &) or [0,2,3,4] (python, C++ ref). But [0,2,3]? It was unpleasant surprise.

Reply via email to