WLPROP bug
When compiling this (originally issue 2467):
inline double +(double a, double b) { return _add_SxS_(a, b); }
inline double *(double a, double b) { return _mul_SxS_(a, b); }
double sum(double[d:shp] x)
{
return with {
(_mul_SxV_(0, shp) <= iv < shp): _sel_VxA_(iv, x);
}: fold(+, 0d);
}
struct Particle {
double x;
double angle;
double y;
};
inline
struct Particle[n]
step_particles(struct Particle[n] particles)
{
particles.x = {iv -> _sel_VxA_(iv, particles.x) * _sel_VxA_(iv, particles.angle)};
particles.y = {iv -> _sel_VxA_(iv, particles.y) + _sel_VxA_(iv, particles.angle)};
return particles;
}
int main() {
particle_count = 20;
particles = {iv -> Particle {.x = 4d,
.y = 100d,
.angle = 1.0}
| iv < [particle_count]};
for (i = 0; _lt_SxS_(i, 10); i = _add_SxS_(i, 1)) {
particles = step_particles(particles);
}
return _toi_S_(sum(particles.x));
}
with sac2c 2.0.0-Tintigny-95-gde1f7
and -bopt
the loop function contains this WL:
_pinl_1169__flat_110 = with /** FOLDABLE (all gen's const) **/
/** REFERENCED: 2 (total num refs) **/
{
/* Partn */
([ 0 ] <= _pinl_1201_iv=[_pinl_1221__eat_524] (IDXS:_wlidx_3239__pinl_1169__flat_110) < [ 20 ] genwidth [ 20 ])
{
_ivesli_3255 = _idxs2offset_( [ 20 ], _pinl_1221__eat_524);
_pinl_1174__flat_217 = _idx_sel_( _ivesli_3255, _dss_977_particles_x) /* no constant offset in dim 1 */;
_pinl_1236__flat_28 = _mul_SxS_( _pinl_1174__flat_217, 4.0);
} : _pinl_1236__flat_28 ;
} :
/* RC (_dss_977_particles_x) */
genarray( [ 20 ], _pinl_1171__flat_145, IDX(_wlidx_3239__pinl_1169__flat_110));
The error lies in the second argument of _mul_SxS_
: this should be 1.0 (angle) instead of 4.0 (x).