Alain D D Williams wrote in
<20221229204511.GC16276@phcomp.co.uk>:
...
|No. i += j += i += i does not contain a sequence point so there is \
|no guarantee
|that anything is completed (eg storing a value in variable i) before \
|another
|part (getting a value from variable i) is evaluated.
But then shell "operators and their precedence, associativity,
and values are the same as in the C language". There are no
sequence points. += is right associative, and then unwound. (For
C, they do it all right, only clang warns on sequencing when
tested. But yes, i do "hate" ISO/IEC JTC1/SC22/WG14, N925, "A
formal model of sequence points and related issues", Clive
Feather, from Y2K (my version), and if only for such cases like
the above. Or the x=++x shown in the committee document (for
exactly that reason i presume: an "easy" formal formula to make it
work, even if human logic gives you the green light).)
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)