...
Consequently, the result of the following noncompliant code depends upon unspecified behavior:
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stdio.h> int g; int f(int i) { g = i; return i; } int main(void) { int x = f(1) + f(2); printf("g = %d\n", g); /* ... */ return 0; } |
...
This compliant solution is independent of the order of evaluation of the operands and can only be interpreted in only one way.
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stdio.h> int g; int f(int i) { g = i; return i; } int main(void) { int x = f(1); x += f(2); printf("g = %d\n", g); /* ... */ return 0; } |
...