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 722754 - Bad C code generated from struct array member initialization
Bad C code generated from struct array member initialization
Status: RESOLVED DUPLICATE of bug 597817
Product: vala
Classification: Core
Component: Structs
0.23.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2014-01-22 05:17 UTC by Arc Riley
Modified: 2017-03-09 21:39 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Arc Riley 2014-01-22 05:17:49 UTC
struct Foo {
    string[] bar;
}

public int main(string[] args) {
    Foo foo = {{"foo", "bar"}};
    stdout.printf(foo.bar[0]);
    return 0;
}

$ valac-0.24 test.vala 
test.vala.c: In function ‘_vala_main’:
test.vala.c:107:15: error: expected expression before ‘{’ token
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
$ valac-0.24 --version
Vala 0.23.1
Comment 1 Arc Riley 2014-01-22 05:24:40 UTC
Genie code where this bug was found;
        profiles = new array of hid_profile[1]
        profiles[0] = {
            "stick",                    // name
            {"X", "Y"},                 // axis
            null,                       // buttons
            false,                      // pointer
            false,                      // text input
            0}                          // touch

Work-around;
        profiles = new array of hid_profile[1]
        profiles[0] = {
            "stick",                    // name
            new array of string[2],     // axis
            null,                       // buttons
            false,                      // pointer
            false,                      // text input
            0}                          // touch
        profiles[0].axis[0] = "X"
        profiles[0].axis[1] = "Y"


Where hid_profile is defined as;

    struct hid_profile
        name : string                   // profile name
        axis : array of string          // how many buttons and their labels
        buttons : array of string       // how many axis and their labels
        pointer : bool                  // pointer position needed
        text : bool                     // text input needed
        touch : int8                    // touch input needed
Comment 2 Rico Tzschichholz 2017-03-09 21:39:29 UTC

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