Chet Ramey wrote:
Description: $ echo $((4000000000*4000000000) -2446744073709551616Repeat-By: Do some arithmetic in bash $((....)). If the numbers are out of range, the output will be wrong in all sorts of interesting ways. No error message is given. Fix: Arbitrary-precision maths would be nice. But at least, could we have an error message if an overflow occurs? The man page says: "Evaluation is done in fixed-width integers with no check for overflow..." but I'd suggest this represents a bug, not a feature.I'm comfortable with the current behavior. POSIX requires that expressions be evaluated according to the C standard, and that standard leaves the treatment of integer overflow as undefined.
If POSIX says the behaviour is undefined, then surely bash can do whatever it wants. So, printing an error message would be allowed.
The error message would be: a)Most helpful to the user (least surprise) b)Consistent with other cases, where bash does give warnings. For example: $ X=$((3+078)) bash: 3+078: value too great for base (error token is "078") $ echo $? 1 Regards, Richard _______________________________________________ Bug-bash mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-bash
