An exemplary 2D array initialization goes like this:
int arr[3][5] = { {0,1,2,3,4}, {5,6,7,8,9}, {10,11,12,13,14} };
We are taught that this is the "correct way" of initializing an array. But is it really "correct" as if it is incorrect to use a single flat-list compound literal? Turns out this is also compilable:
int arr[3][5] = { 0,1,2,3,4, 5,6,7,8,9, 10,11,12,13,14 };
(Which probably has to do with the fact that all array elements are laid out in contiguous memory.)
In terms of lexics, both codes compile and seemingly produce the same result in GCC. The former evidently wins in terms of readability, except in some cases it makes it worse. And I don't see why we can't just separate "dimensions" with spaces as I just did. I am particularly interested in exactly what this means to the compiler. I was not able to make it produce warnings that can only depend on the presence of curly braces. Excess elements can be detected either way. If the only problem is in the compiler's diagnostic, then I would like to know which warnings/errors fire up only when braces are present.