bug-bash
[Top][All Lists]
Advanced

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

Re: nitpick: a=([9223372036854775807]=1 2 3)


From: Chet Ramey
Subject: Re: nitpick: a=([9223372036854775807]=1 2 3)
Date: Tue, 16 Dec 2014 22:04:53 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 12/16/14 5:10 PM, Stephane Chazelas wrote:
> bash-4.3$ a=([9223372036854775806]=1 2 3 4)
> bash-4.3$ echo "${!a[@]}"
> -9223372036854775808 -9223372036854775807 9223372036854775806 
> 9223372036854775807
> 
> That wraps but as signed longs, which means we get negative
> indexes which we can't easily use.

OK.  Array indices are arithmetic expressions.  From the man page:

"Evaluation  is done in fixed-width integers with no check for overflow"

They're not checked.
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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