How initialize a static rectangular array (2-d matrix)
Ellery Newcomer
ellery-newcomer at utulsa.edu
Thu Oct 8 19:11:03 PDT 2009
Justin Johansson wrote:
> Jarrett Billingsley Wrote:
>
>> On Thu, Oct 8, 2009 at 8:10 PM, Justin Johansson <no at spam.com> wrote:
>
> Thanks Jarrett.
>
> Am I having a blonde day?
>
> int[2,3] m = [ 1, 2, 3 ];
> writefln( "m=%s, .sizeof=%d", m, m.sizeof);
>
> Compiles and prints:
>
> m=[1,2,3], .sizeof=12
>
> So what does that declaration, int[2,3], mean?
>
> Think this is what threw me initially.
>
> Thanks, Justin
>
It probably means DMD isn't doing enough validation checking.
Comma expression, hence typeof(m) is int[3], m.sizeof is 3 * int.sizeof
More information about the Digitalmars-d-learn
mailing list