[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Arithmetic expression: evaluation order bug
From: |
Steffen Nurpmeso |
Subject: |
Re: Arithmetic expression: evaluation order bug |
Date: |
Thu, 29 Dec 2022 22:30:09 +0100 |
User-agent: |
s-nail v14.9.24-383-g2889cb06b9 |
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)
- Arithmetic expression: evaluation order bug, Steffen Nurpmeso, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Alain D D Williams, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Steffen Nurpmeso, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Emanuele Torre, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Alain D D Williams, 2022/12/29
- Re: Arithmetic expression: evaluation order bug,
Steffen Nurpmeso <=
- Re: Arithmetic expression: evaluation order bug, Alain D D Williams, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Andreas Schwab, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Steffen Nurpmeso, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Andreas Schwab, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Steffen Nurpmeso, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Andreas Schwab, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Steffen Nurpmeso, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Steffen Nurpmeso, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Steffen Nurpmeso, 2022/12/29
- Re: Arithmetic expression: evaluation order bug, Greg Wooledge, 2022/12/29