bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bash 2.05 arithmetic expr status incorrect on 64-bit hosts


From: Paul Eggert
Subject: Bash 2.05 arithmetic expr status incorrect on 64-bit hosts
Date: Sun, 29 Apr 2001 19:11:23 -0700 (PDT)

Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.7
Compiler: cc -xarch=v9
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc' 
-DCONF_OSTYPE='solaris2.7' -DCONF_MACHTYPE='sparc-sun-solaris2.7' 
-DCONF_VENDOR='sun' -DSHELL  -DHAVE_CONFIG_H  -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I.  -I.. -I../include -I../lib 
-I/tmp/prefix/include -g
uname output: SunOS sic.twinsun.com 5.7 Generic_106541-15 sun4u sparc 
SUNW,UltraSPARC-IIi-Engine
Machine Type: sparc-sun-solaris2.7

Bash Version: 2.05
Patch Level: 0
Release Status: release

Description:
        When computing the exit status of an arithmetic expression,
        Bash 2.05 converts the result to 'int' before testing whether
        it is nonzero.  This mishandles values larger than 2**31.
        Bash should test the result without truncating it.

Repeat-By:
        $ ((4294967296)) || echo bug
        bug


Fix:

2001-04-29  Paul Eggert  <eggert@twinsun.com>

        * execute_cmd.c (execute_arith_command): Test entire
        arithmetic value against zero, not just the part that fits
        into 'int'.  Remove unused local var 'expresult'.

===================================================================
RCS file: execute_cmd.c,v
retrieving revision 2.5.0.3
retrieving revision 2.5.0.4
diff -pu -r2.5.0.3 -r2.5.0.4
--- execute_cmd.c       2001/04/13 08:15:26     2.5.0.3
+++ execute_cmd.c       2001/04/30 02:06:02     2.5.0.4
@@ -2144,7 +2144,8 @@ static int
 execute_arith_command (arith_command)
      ARITH_COM *arith_command;
 {
-  int result, expok, expresult;
+  long result;
+  int expok;
   WORD_LIST *new, *p, *printit;
   WORD_DESC *w;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]