Dividing by zero isn't the only cause of SIGFPE.
fmttest -raw -format '%(num -
2147483648) %(divide -1)' foo
Also, add FIXME comment suggesting the user should be told of overflow
rather than silently using zero as the result.
value *= fmt->f_value;
break;
case FT_LV_DIVIDE_L:
- if (fmt->f_value)
- value /= fmt->f_value;
- else
+ if (fmt->f_value == 0 || (fmt->f_value == -1 && value == INT_MIN)) {
+ // FIXME: Tell the user, and probably stop.
value = 0;
+ } else {
+ value /= fmt->f_value;
+ }
break;
case FT_LV_MODULO_L:
if (fmt->f_value)
value %= fmt->f_value;
else
+ // FIXME: Tell the user, and probably stop.
value = 0;
break;
case FT_SAVESTR: