In the following code
int main(){
int a=3;
printf("%d %d %d",++a,a,a++);
return 0;
}
As indicated, from the application C99 C :,
The following are the sequence points described in 5.1.2.3:
- A function call after evaluating the arguments (6.5.2.2).
- The end of the first operand of the following operators: logical AND && (6.5.13); logical OR || (6.5.14); conditional? (6.5.15); comma (6.5.17)
The order in which function arguments are evaluated is undefined, as specified in the C standard.
However, in a function call for printf, we have comma-separated arguments that are classified as sequence points. So why does this statement correspond to unspecified behavior?
source
share