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.

<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

Reply via email to