#include <stdio.h>
int main() { int i=0; printf("%d %d %d %d %d %d", i++, i++, i++, i++, i, i++);
return 0;
}
Asked
Active
Viewed 37 times
-1

Mat
- 202,337
- 40
- 393
- 406
-
Take a look at the disassembly ? – Sorenp Jan 08 '21 at 07:55
-
See [Why can't we mix increment operators like i++ with other operators?](https://software.codidact.com/posts/278384). – Lundin Jan 08 '21 at 09:42
1 Answers
0
Compiler can evaluate the code in whatsoever way it wants.
But what is specified by the standard, is that modifying the same variable twice in one operation is undefined behavior; ISO C++03, 5[expr]/4:
You should not write print the statements this way for unary operators.

Jayesh
- 3
- 5