bug-bash
[Top][All Lists]
Advanced

[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 00:15:38 +0100
User-agent: s-nail v14.9.24-383-g2889cb06b9

Ah, wait..

Alain D D Williams wrote in
 <20221229215700.GD16276@phcomp.co.uk>:
 ...
 |Anyway: back to what the shell should be doing. You cannot put a ';' \
 |into (( ))
 |as a sequence point, but the manual does say:
 |
 |"Sub-expressions in parentheses are evaluated first and may override the
 |precedence rules above"
 |
 |So use sub-expressions to 'evaluate first' so you should prolly rewrite:
 |
 |(( i += j += i += i ))
 |
 |as:
 |
 |(( i += (j += (i += i)) ))

I had tried that with clang (and now with gcc -Wall).

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



reply via email to

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