mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-07 20:52:45 +02:00
(eval4): Detect overflow properly when multiplying INTMAX_MIN * -1.
This commit is contained in:
@@ -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.)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user