[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: 
Fri, 30 Dec 2022 16:48:15 +0100 
Useragent: 
snail v14.9.24383g2889cb06b9 
Robert Elz wrote in
<10111.1672392203@jacaranda.noi.kre.to>:
...
The way to make this work is to insert sequence points, of which there
is only one which is plausible in shell arithmetic expressions, and even
that isn't required to exist by POSIX.

 $(( i += i, j += i, i += j ))

for that expression (and similar for the other one) is defined in C, and
so should be implemented the same way by all shells, and is, at least by
those which actually implement the ',' operator (which excludes dash,
the FreeBSD sh, and yash). Affected people might want to apply some
pressure to the implementors of those to add the required support, it is
trivial to do (just multiple expressions, evaluated one after another).

For what it is worth, I tested a bunch of shells with the original
expressions, all ksh variants, bosh, and bash evaluate the original
expressions the bash way, all ash variants, plus yash and zsh implement
it the dash way. Neither is incorrect.
Thanks  i should have done that, and if only out of interest
(but have only three shells here). Yes, comma is not always
supported. Of course i continue to disagree as i continue to
disagree on much of the sequence point outcome of ISO C, too.
(Granted that many cultures do it righttoleft or toptobottom
instead. And i like his dove RFC, that was he, i think. Those
doves are heroes! Yes, one day there was noise on my working room
window, but i sent him away, but of all windows it was mine in
particular, he tried and tried, did not want to be helped in when
i finally opened, pointed me to the ring on the leg, so
i contacted the owner, still 200 kilometres away, disappointed,
strong wind it was, shit was green, totally exhausted, (very!)
good food for two days, then brought him to the president of the
local dove club so he could have look (i was not loved for this
needless decision), and i was later called back as he got home
after doing the remaining 30 percent, and i cheered through the
telephone which was all i could do; 'flew by to say hello many
months later, or a year, "this time i make it!" (very same
journey!), .. and some years later even went through the room,
which i found unbelievable. A real and unforgotten character.)
Ciao,
(P.S.: leaving doves where they belong.)
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)
 Re: Arithmetic expression: evaluation order bug, (continued)
 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
 Re: Arithmetic expression: evaluation order bug, Steffen Nurpmeso, 2022/12/30
 Re: Arithmetic expression: evaluation order bug, Alain D D Williams, 2022/12/30
 Re: Arithmetic expression: evaluation order bug, Robert Elz, 2022/12/30
 Re: Arithmetic expression: evaluation order bug,
Steffen Nurpmeso <=
 Re: Arithmetic expression: evaluation order bug, Robert Elz, 2022/12/30