diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/expr.c | 4 |
2 files changed, 9 insertions, 2 deletions
@@ -1,7 +1,12 @@ -2006-06-06 Paul Eggert <eggert@cs.ucla.edu> +2006-06-07 Paul Eggert <eggert@cs.ucla.edu> * Version 6.0-cvs. + * src/expr.c (eval4): Detect overflow properly when multiplying + INTMAX_MIN * -1. + +2006-06-06 Paul Eggert <eggert@cs.ucla.edu> + * NEWS: The 'expr' command now detects and reports integer overflow. (It would be better to use extended precision instead, but that would be more work.) diff --git a/src/expr.c b/src/expr.c index 7b5c77be6..e0510fc10 100644 --- a/src/expr.c +++ b/src/expr.c @@ -640,7 +640,9 @@ eval4 (bool evaluate) if (fxn == multiply) { val = l->u.i * r->u.i; - if (! (l->u.i == 0 || val / l->u.i == r->u.i)) + if (! (l->u.i == 0 || r->u.i == 0 + || ((val < 0) == ((l->u.i < 0) ^ (r->u.i < 0)) + && val / l->u.i == r->u.i))) integer_overflow ('*'); } else |