GNOME Bugzilla – Bug 628030
valac generates invalid code for const multidimensional arrays
Last modified: 2018-02-21 08:53:20 UTC
Compiling the following test program with valac-0.9.3: class Test : Object { public static const string[,] ARRAY = { { "one", "1" }, { "two", "2" } }; public static int main(string[] args) { var x = ARRAY[0,1]; return 0; } } produces invalid C for the declaration and usage of the multidimensional array. The array is declared as: const char* TEST_ARRAY[2] = {{"one", "1"}, {"two", "2"}}; It is accessed as: x = g_strdup (TEST_ARRAY[(0 * G_N_ELEMENTS (TEST_ARRAY)) + 1]); It appears that in both cases, the second dimension is not being accounted for properly. When the const qualifier is removed, valac emits valid code but the array is initialised at runtime, not statically.
*** This bug has been marked as a duplicate of bug 604371 ***