[Top][All Lists]

[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
 |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 \
 |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).)

|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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]