Compound Assignments (was Re: Another <sigh> error!)
Tim Olson
tim at proton.amd.com
Sun Apr 7 05:59:01 AEST 1991
In article <1991Apr4.205257.15205 at mccc.edu> pjh at mccc.edu (Peter J. Holsberg) writes:
| Where/how does the standard explain that an expression such as
|
| x[i++] *= y;
|
| has the "x[i++]" part evaluated only once, while an expression such as
|
| x *= y;
|
| has the "x" part evaluated twice, as in
|
| x = x * y;
In the second example, "x" is not evaluated twice -- it is evaluated
only once, just as in the first example. The standard says just this
in 3.3.16.2 (Compound assignment):
Semantics
A compound assignment of the form E1 op= E2 differs from the
simple assignment expression E1 = E1 op (E2) only in that the
lvalue E1 is evaluated only once.
--
-- Tim Olson
Advanced Micro Devices
(tim at amd.com)
More information about the Comp.lang.c
mailing list