No bounds checking for dynamic arrays at compile time?

Gopan Gopan.Gopalakrishnan at gmail.com
Thu Dec 13 06:47:52 PST 2012


import std.stdio;

void main()
{
	int[3][2] matrix = [ [1,11,111], [2,22,222] ];

	foreach(int[5] row; matrix) //if int[3], there is no error.
	{
              foreach(x; row)
		write(x, "  ");
		
	     writeln();
	}
}

I get runtime error for the above code too.

Application error:
object.Exception at src/rt/arraycat.d(31): lengths don't match for 
array copy


Why didn't I get a compilation error?  All the array sizes are 
known at compile time.  Right?


More information about the Digitalmars-d mailing list