bug-bash
[Top][All Lists]
Advanced

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

Re: Segmentation fault in arithmetical expression when mixing array vari


From: Dan Douglas
Subject: Re: Segmentation fault in arithmetical expression when mixing array variables.
Date: Wed, 09 Jan 2013 16:31:48 -0600
User-agent: KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; )

On Wednesday, January 09, 2013 10:15:31 AM Eduardo A. Bustamante López wrote:
> Hi!
> 
> I found an issue while using array variables in an arithmetical
> context. I tried to determine where the problem was, but I didn't
> understand expr.c. The backtrace points to expr.c's line 556, in
> expassing. I tested both the master and devel branches.
> 
> 
> 
-------------------------------------------------------------------------------
> Script
> 
-------------------------------------------------------------------------------
> #!/bin/bash
> 
> echo "$BASH_VERSION"
> echo $(( a=(y[0] + y[1]) & 0xff, b=(y[2] + y[3]) & 0xff, a << 8 | b))
> 
-------------------------------------------------------------------------------

With 5 minutes of experimenting, it occurs here any time there is more than 
one assignment in an expression where the first refers to an array index.

$ ( y=(1 2); (( _ = y, _ = 1 )) )    # No error
$ ( y=(1 2); (( _ = y[0], _ = 1 )) ) # crash
Segmentation fault
$ ( y=(1 2); (( _ = y[0] )) ) # No error

lvalue doesn't matter. It's just any two assignments in which the first 
dereferences an array with an index given.
-- 
Dan Douglas



reply via email to

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