>
> 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 gcc both
> throw warnings about it, but both plus icc agree on 2.
Interesting. So it's good to better avoid such cascades in ksh.
Thanks for pointing that out!
Janis
>
> <stdin>:1:42: warning: unsequenced modification and access to 'x'
> [-Wunsequenced]
> int main() { int x=0; printf("%d\n", x+=x=1); return 0; }
> ~~ ^
> 1 warning generated.
> 2
> --
> Dan Douglas
> _______________________________________________
> ast-users mailing list
> [email protected]
> http://lists.research.att.com/mailman/listinfo/ast-users