My understanding of the whole point of the sequence of things is basic. All I have is a crude intuitive idea: "When a sequence point occurs, we can be sure that all the side effects of previous evaluations are complete." I also read that in expressions like printf("%d",a++,++a,a++) , the behavior is undefined, since the comma does not indicate a sequence point, while the semicolon is executed. Therefore, instead of speculating and going on intuition, I feel that a very strict and convincing answer to this will help me a lot.
So in C:
The following statements exist:
int a=4,*ptr=&a;
If so, how? Especially in the second case, if the comma is not a point in the sequence, how can we be sure that x been increased by 4 before we use it in the assignment y=x*2 ? And for the first statement, how can I be sure that a been initialized and allocated memory before I assign its ptr address? Should I play in safe mode and use the following for the above:
int a=4,*ptr; ptr=&a;
and
x+=4; y=x*2;
Change My understanding of the comma operator tells me that these statements are safe. But after reading about the points in the sequence and like something like printf("%d",a++,++a,a++) is undefined, I have other thoughts.
source share