As mentioned in the comp.lang.c FAQ, the C standard states:
Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be accessed only to determine the value to be stored.
But, this (now deleted) article says that a = ++b + ++c;
is undefined. Could someone please explain why this is undefined behaviour?
Provided the objects involved (a
, b
and c
) in the expression a = ++b + ++c;
are distinct, that expression is well-defined.
Perhaps, the author meant to use the same variable twice such as a = ++b + ++b;
. I can only speculate. But there's no undefinedness in the given expression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With