On Sun, Aug 4, 2013 at 12:04 AM, Dan Douglas wrote:
> Is it specified what the value of x should be after this expression?
>
> x=0; : $((x+=x=1))
>
> Bash, ksh93, mksh, posh say 1. zsh, dash, busybox say 2. Clang and gcc both
> throw warnings about it, but both plus icc agree on 2.
Just curious:
>
> Is it specified what the value of x should be after this expression?
Typically assignment cascades (including the op= variants) are
evaluated from right to left...
>
> x=0; : $((x+=x=1))
...so this would produce 2.
>
> Bash, ksh93, mksh, posh say 1. zsh, dash, busybox say 2. Clang and gc
On Sun, Aug 4, 2013 at 12:41 AM, Dan Douglas wrote:
> On Sunday, August 04, 2013 12:30:48 AM Roland Mainz wrote:
>> On Sun, Aug 4, 2013 at 12:04 AM, Dan Douglas wrote:
>> > Is it specified what the value of x should be after this expression?
>> >
>> > x=0; : $((x+=x=1))
>> >
>> > Bash, ksh93, mks
On Sunday, August 04, 2013 12:30:48 AM Roland Mainz wrote:
> On Sun, Aug 4, 2013 at 12:04 AM, Dan Douglas wrote:
> > Is it specified what the value of x should be after this expression?
> >
> > x=0; : $((x+=x=1))
> >
> > Bash, ksh93, mksh, posh say 1. zsh, dash, busybox say 2. Clang and gcc
> > b
Is it specified what the value of x should be after this expression?
x=0; : $((x+=x=1))
Bash, ksh93, mksh, posh say 1. zsh, dash, busybox say 2. Clang and gcc both
throw warnings about it, but both plus icc agree on 2.
:1:42: warning: unsequenced modification and access to 'x'
[-Wunsequenced]
i