WLSIMP leads to wrong results; bug in SCSisRelationalOnDyadicFn
When compiling and running the following code using sac2c WLSIMP-bug.sac ; ./a.out ; echo $?
we obtain 11
.
When using sac2c WLSIMP-bug.sac -noWLSIMP; ./a.out ; echo $?
we obtain the correct 42
.
I use the latest release compiler sac2c 1.3.3-MijasCosta-926-gec84e9
.
noinline
int[12,10] interp2x (int[12,10] phi, int[2] boundary_sizes)
{
// if the following line is inserted, the bug disappears!
// boundary_sizes = [1,1];
return with {
(boundary_sizes <= iv < _sub_VxV_( [12,10], boundary_sizes) ) : _sel_VxA_ (iv,interp2x (phi)) ;
} : modarray (phi);
}
inline
int[11,9] interp2x (int[12,10] phi)
{
return with {
( . <= [i,j] <= .) : 42;
} : genarray ([11,9], 0);
}
int main()
{
v = with {
([0,0] <= [i,j] <[12,10]) : _add_SxS_(_mul_SxS_(i,10),j);
} : genarray ( [12,10], 0);
v2 = interp2x (v, [1,1]);
// return value should be 42, not 11!
return (_sel_VxA_([1,1], v2));
}