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 597817 - array in struct initialization produce uncompilabel code
array in struct initialization produce uncompilabel code
Status: RESOLVED DUPLICATE of bug 741491
Product: vala
Classification: Core
Component: Structs
0.35.x
Other Linux
: Normal normal
: 1.0
Assigned To: Vala maintainers
Vala maintainers
: 722754 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-10-08 15:01 UTC by picca
Modified: 2017-03-09 21:42 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description picca 2009-10-08 15:01:30 UTC
Hello I attached a test.vala file that do not compile


To resume I create a struct with an array then I try to initialize it using members of another struct, like this

struct VectorA { double data[3];}

VectorA veca = {{other.x, other.y, other.z}};

the C code generated produce this:

struct _VectorA {
        double data[3];
};

and the wrong part

90:veca = (_tmp1_.data = {vec.x, vec.y, vec.z}, _tmp1_);

the error message is:

picca@grisette:/tmp$ valac test.vala 
/tmp/test.vala.c: In function ‘_main’:
/tmp/test.vala.c:90: error: expected expression before ‘{’ token
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

is it normal or I did something wrong ?

thanks

Frédéric
Comment 1 picca 2009-10-08 15:06:31 UTC
I can not attach the file ??? so I copy here the content (short)

struct VectorA {
        double data[3];
}

struct VectorB {
        double x;
        double y;
        double z;
}


void main() {
        VectorB vec= {1, 2, 3};
        VectorA veca = {{vec.x, vec.y, vec.z}};

        assert (veca.data[0] == 1);
        assert (veca.data[1] == 2);
        assert (veca.data[2] == 3);
}
Comment 2 Rico Tzschichholz 2017-03-09 21:39:29 UTC
*** Bug 722754 has been marked as a duplicate of this bug. ***
Comment 3 Rico Tzschichholz 2017-03-09 21:42:07 UTC

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