sac2c issueshttps://gitlab.sac-home.org/sac-group/sac2c/-/issues2021-09-06T19:43:52Zhttps://gitlab.sac-home.org/sac-group/sac2c/-/issues/12872D array assignment in for loops2021-09-06T19:43:52ZRobert Stewart2D array assignment in for loops| | |
| --- | --- |
| Bugzilla Link | [1141](http://bugs.sac-home.org/show_bug.cgi?id=1141) |
| Created on | Oct 29, 2014 15:25 |
| Version | svn |
| OS | Linux |
| Architecture | PC |
## Extended Description
<pre>This code compiles ...| | |
| --- | --- |
| Bugzilla Link | [1141](http://bugs.sac-home.org/show_bug.cgi?id=1141) |
| Created on | Oct 29, 2014 15:25 |
| Version | svn |
| OS | Linux |
| Architecture | PC |
## Extended Description
<pre>This code compiles just fine:
int main()
{
xs = [1,2,3];
for( i=0; i<3; i++) {
xs[i] = 5;
}
return 1; }
The following very similar code does not compile. The only difference is that it is assigning to a 2D array, rather than a 1D array as before.
int main()
{ xss = [[1,2,3],[4,5,6]];
for( i=0; i<2; i++) {
for( j=0; j<2; j++) {
xss[i][j] = 5;
}
}
return 1; }
The compile error is:
$ sac2c test.sac
./test.sac 5:35 error:
=> token `;' expected, `=' token found
abort: Failed to construct a syntax tree for `test.sac'
compilation failed while Loading SAC program, 1 error(s).
Line 5 is `xss[i][j] = 5;`.</pre>Artem ShinkarovArtem Shinkarov