Pre/Post increment expression as array index broken
I discovered a vala bug that was created in the new version, with vala 0.48 this code works but not in the current vala.
void main()
{
int tab[5];
int i = 0;
tab[i++] = 'a';
tab[i++] = 'b';
tab[i++] = 'c';
tab[i++] = 'd';
tab[i++] = 'e';
foreach(var e in tab){
print("%c\n", e);
}
}
vala 0.48 C generation:
gint tab[5] = {0};
gint i = 0;
gint _tmp0_;
gint _tmp1_;
gint _tmp2_;
gint _tmp3_;
gint _tmp4_;
i = 0;
_tmp0_ = i;
i = _tmp0_ + 1;
tab[_tmp0_] = (gint) 'a';
_tmp1_ = i;
i = _tmp1_ + 1;
tab[_tmp1_] = (gint) 'b';
_tmp2_ = i;
i = _tmp2_ + 1;
tab[_tmp2_] = (gint) 'c';
_tmp3_ = i;
i = _tmp3_ + 1;
tab[_tmp3_] = (gint) 'd';
_tmp4_ = i;
i = _tmp4_ + 1;
tab[_tmp4_] = (gint) 'e';
vala 0.56 generation:
gint tab[5] = {0};
gint i = 0;
gint _tmp0_[5];
gint _tmp0__length1;
gint _tmp1_;
gint _tmp2_[5];
gint _tmp2__length1;
gint _tmp3_;
gint _tmp4_[5];
gint _tmp4__length1;
gint _tmp5_;
gint _tmp6_[5];
gint _tmp6__length1;
gint _tmp7_;
gint _tmp8_[5];
gint _tmp8__length1;
gint _tmp9_;
i = 0;
memcpy (_tmp0_, tab, 5 * sizeof (gint));
_tmp1_ = i;
i = _tmp1_ + 1;
_tmp0_[_tmp1_] = (gint) 'a';
memcpy (_tmp2_, tab, 5 * sizeof (gint));
_tmp3_ = i;
i = _tmp3_ + 1;
_tmp2_[_tmp3_] = (gint) 'b';
memcpy (_tmp4_, tab, 5 * sizeof (gint));
_tmp5_ = i;
i = _tmp5_ + 1;
_tmp4_[_tmp5_] = (gint) 'c';
memcpy (_tmp6_, tab, 5 * sizeof (gint));
_tmp7_ = i;
i = _tmp7_ + 1;
_tmp6_[_tmp7_] = (gint) 'd';
memcpy (_tmp8_, tab, 5 * sizeof (gint));
_tmp9_ = i;
i = _tmp9_ + 1;
_tmp8_[_tmp9_] = (gint) 'e';
vala 0.48 output: "abcde"
vala 0.56 output: ""
Edited by Hydral Nathan Jordan