C
ccwork
p = p->next = q;
Why it is undefined?
operator "=" is right-associative i.e. "p = p->next = q;" is
equivalent to "p = (p->next = q);
And I think another interpretation of sequence point is: between 2
sequence point a variable cannot be modified twice. In "p = p->next =
q;", "p->next" is modified once, "p" is modified once. (Let say we use
another pointer "k" such that "k=p->next" and then "p = p->next = q;"
become "p = k = q". Obviously the "k" and "p" are modified once
individually.)
Why it is undefined?
operator "=" is right-associative i.e. "p = p->next = q;" is
equivalent to "p = (p->next = q);
And I think another interpretation of sequence point is: between 2
sequence point a variable cannot be modified twice. In "p = p->next =
q;", "p->next" is modified once, "p" is modified once. (Let say we use
another pointer "k" such that "k=p->next" and then "p = p->next = q;"
become "p = k = q". Obviously the "k" and "p" are modified once
individually.)