Comment #0 by bearophile_hugs — 2015-10-11T11:25:55Z
void main() {
int[2][2] m = [1, 2, 3, 4];
}
Comment #1 by wyatt.epp — 2015-10-13T19:14:09Z
The documentation on Arrays states that a static matrix declaration is contiguous in memory so I'd guess this is actually intentional? Or at least tacitly approved as a holdover from C? D doesn't really seem to have a strong concept of rank or shape and, from what I could decipher of the grammar, this scenario isn't really covered.
Does this also indicate the need for a rho or reshape function?
Comment #2 by bearophile_hugs — 2015-10-13T20:50:36Z
(In reply to Wyatt from comment #1)
> The documentation on Arrays states that a static matrix declaration is
> contiguous in memory so I'd guess this is actually intentional?
A serious language needs should not be sloppy.
Comment #3 by wyatt.epp — 2015-10-14T12:31:34Z
(In reply to bearophile_hugs from comment #2)
>
> A serious language needs should not be sloppy.
I wasn't arguing in favour of the current behaviour so much as pointing out why it might be like that at all. I agree that it's wrong.
Comment #4 by dlang-bugzilla — 2015-10-15T20:30:40Z
This is obviously a bug because if you make the array static, you get an error. This only applies to non-static array initialization, which has no reason to be syntactically inconsistent.
Comment #5 by robert.schadek — 2024-12-13T18:45:15Z