|
|
Bugzilla Link |
564 |
Created on |
Sep 23, 2009 15:15 |
Resolution |
FIXED |
Resolved on |
Dec 11, 2009 17:35 |
Version |
1.00beta |
OS |
Linux |
Architecture |
PC |
Extended Description
Compiler version:
sac2c v1.00-beta (Buchette d'Anjou)
product rev 16226 linux-gnu_i686
(Fri Jul 24 15:22:58 BST 2009 by asv)
Summary:
When I use in the body of function construction:
array = genarray([x, 2, 10], 0);
where `x` is a parameter of the function, I get a very strange runtime when I iterate through the outer dimension of the array.
Example:
use Array: {genarray, modarray, sel };
use StdIO: {printf, print};
int[.,.,.] f(int limit) {
int[.,.,.] array;
array = genarray([limit,2,10], 0);
for (gr = 0; _lt_SxS_(gr, limit); gr = _add_SxS_(gr, 1)) {
maxlen = 7;
for (i = 2; _lt_SxS_(i, 5); i = _add_SxS_(i, 1)) {
array[gr, 0, i] = 10;
array[gr, 1, _add_SxS_(i,1)] = 11;
printf("i = %i\n", i);
}
printf("array[%i, %i, %i] = 13\n", gr, 1, maxlen);
array[gr, 1, maxlen] = 13;
printf("array[%i, %i, %i] = %i\n", gr, 1, maxlen, array[gr, 1, maxlen]);
print(array);
}
print(array[0,1,3]);
print(array[1,1,3]);
return (array);
}
-----------------------------------------------------------------
Execution:
When I call the function with parameter `2`: f(2), I get the following:
i = 2
i = 3
i = 4
array[0, 1, 7] = 13
array[0, 1, 7] = 13
Dimension: 3
Shape : < 2, 2, 10>
< 0 0 10 10 10 0 0 0 0 0 > < 0 0 0 11 11 11 0 13 0 0 >
< 0 0 0 0 0 0 0 0 0 0 > < 0 0 0 0 0 0 0 0 0 0 >
i = 2
i = 3
i = 4
array[1, 1, 7] = 13
array[1, 1, 7] = 13
Dimension: 3
Shape : < 2, 2, 10>
< 0 0 10 10 10 0 0 0 0 0 > < 0 0 0 11 11 11 0 13 0 0 >
< 0 0 10 0 0 0 0 0 0 0 > < 0 0 0 11 0 0 0 0 0 0 >
Dimension: 0
Shape : < >
13
Segmentation fault
-----------------------------------------------------------------------
So we can see that array is not updated and access to the valid address
of the array gives us Segmentation fault.
The problem goes away if I'll use static values in genarray, like
array = genarray([2,2,10], 0);