Created attachment 1774
Сast nested array from static to dynamic.
Version: v2.090.0
Comment #1 by moonlightsentinel — 2020-01-30T19:34:12Z
The cast from int[2][2] to int[][] is invalid - you cannot slice across multiple dimensions.
import std.stdio;
void main(string[] args)
{
int[2][2] e = [[1,2],[3,4]];
int[][] c = cast(int[][]) e;
writeln(c.length); // 1
writeln(c[0].length); // 8589934593
int[2][] valid = e; // no cast needed
writeln(valid); // [[1, 2], [3, 4]]
}
The length of a static array is only known at compile time while the length of a dynamic array is a runtime value. Hence c's length is set to some garbage from the stack.