After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 628030 - valac generates invalid code for const multidimensional arrays
valac generates invalid code for const multidimensional arrays
Status: RESOLVED DUPLICATE of bug 604371
Product: vala
Classification: Core
Component: Code Generator: GObject
0.9.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-08-26 13:04 UTC by Dan Callaghan
Modified: 2018-02-21 08:53 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dan Callaghan 2010-08-26 13:04:13 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.
Comment 1 Michael 'Mickey' Lauer 2018-02-21 08:53:20 UTC

*** This bug has been marked as a duplicate of bug 604371 ***