M
Mark Turney
I was reading "Practical C++ Programming" yesterday, and it mentioned
that the order of execution for post-increment and post-decrement
operators was ambiguous.
I had previously learned that a post-increment or post-decrement
operator modifies the operand once the entire statement has been
executed, not during execution of the statement, so this confused me.
An examples given to illustrate the ambiguity is:
a = i++; // may increment i before or after a is evaluated.
I tested with the VC6 compiler and the gnu compiler, but with the same
results: the post-decrement occurs after the entire statement is
executed, not during it's execution.
I have now been told that the actual ANSI C++ Standard is ambiguous
concerning execution order (regardless of what occurs during
compilation with different compiler makers).
I am still in the process of working my way through C++ and I don't
have a copy of the official standard, so I was hoping a more learned
individual would be able to elucidate this troublesome issue for me.
"Pracitcal C++ Programming" recommends against the use of increment
and decrement operators within statements, but I've learned to really
enjoy them.
Thanks for the help
-mark
that the order of execution for post-increment and post-decrement
operators was ambiguous.
I had previously learned that a post-increment or post-decrement
operator modifies the operand once the entire statement has been
executed, not during execution of the statement, so this confused me.
An examples given to illustrate the ambiguity is:
a = i++; // may increment i before or after a is evaluated.
I tested with the VC6 compiler and the gnu compiler, but with the same
results: the post-decrement occurs after the entire statement is
executed, not during it's execution.
I have now been told that the actual ANSI C++ Standard is ambiguous
concerning execution order (regardless of what occurs during
compilation with different compiler makers).
I am still in the process of working my way through C++ and I don't
have a copy of the official standard, so I was hoping a more learned
individual would be able to elucidate this troublesome issue for me.
"Pracitcal C++ Programming" recommends against the use of increment
and decrement operators within statements, but I've learned to really
enjoy them.
Thanks for the help
-mark