[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bash-bug] Can arithmetic evaluation trap more than just division by
From: |
Dr. Werner Fink |
Subject: |
Re: [bash-bug] Can arithmetic evaluation trap more than just division by zero? |
Date: |
Tue, 6 Apr 2010 15:44:22 +0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Tue, Apr 06, 2010 at 08:35:13AM -0400, Greg Wooledge wrote:
> On Tue, Apr 06, 2010 at 02:21:05PM +0200, Roman Rakus wrote:
> > >>$((2 ** 63 / -1))
>
> > I can reproduce it in 4.1.2(1)-release and 4.0.23(1)-release on x86_64
> > GNU/Linux. I didn't try on bash 3.2.
>
> cyclops:~$ uname -a; echo $BASH_VERSION
> OpenBSD cyclops.wooledge.org 4.6 GENERIC.MP#81 amd64
> 4.0.24(1)-release
> cyclops:~$ echo $((2 ** 63 / -1))
> Connection to cyclops closed.
> griffon:~$
>
> An amd64-specific bug, then? (The Linux box I tested on earlier is i386,
> and the HP-UX box is PA-RISC 2.0.)
On x86_64 I see:
~> echo $((2 ** 63 / -1))
Floating exception
whereas on i686
~> echo $((2 ** 63 / -1))
-9223372036854775808
... both GNU/Linux. On x86_64 the gdb shows:
Program received signal SIGFPE, Arithmetic exception.
0x0000000000462cd5 in exp2 () at expr.c:761
761 val1 /= val2;
(gdb) print val1
$1 = -9223372036854775808
(gdb) print val2
$2 = -1
which is strange.
Werner
--
"Having a smoking section in a restaurant is like having
a peeing section in a swimming pool." -- Edward Burr
- Can arithmetic evaluation trap more than just division by zero?, Roman Rakus, 2010/04/06
- Re: Can arithmetic evaluation trap more than just division by zero?, Greg Wooledge, 2010/04/06
- Re: Can arithmetic evaluation trap more than just division by zero?, Roman Rakus, 2010/04/06
- Re: Can arithmetic evaluation trap more than just division by zero?, Greg Wooledge, 2010/04/06
- Re: [bash-bug] Can arithmetic evaluation trap more than just division by zero?,
Dr. Werner Fink <=
- Re: [bash-bug] Can arithmetic evaluation trap more than just division by zero?, Andreas Schwab, 2010/04/06
- Re: [bash-bug] Can arithmetic evaluation trap more than just division by zero?, Roman Rakus, 2010/04/06
- Re: [bash-bug] Can arithmetic evaluation trap more than just division by zero?, Andreas Schwab, 2010/04/06
- Re: [bash-bug] Can arithmetic evaluation trap more than just division by zero?, John Reiser, 2010/04/06
- Re: [bash-bug] Can arithmetic evaluation trap more than just division by zero?, Roman Rakus, 2010/04/06
- Re: [bash-bug] Can arithmetic evaluation trap more than just division by zero?, Chet Ramey, 2010/04/06
- Re: Can arithmetic evaluation trap more than just division by zero?, Roman Rakus, 2010/04/06
Re: Can arithmetic evaluation trap more than just division by zero?, Roman Rakus, 2010/04/07