Is “*p = ++(*q)” undefined when p and q point to the same object?

后端 未结 5 1651
天命终不由人
天命终不由人 2021-02-13 22:02

after reading about sequence points, I learned that i = ++i is undefined.

So how about this code:

int i;
int *p = &i;
int *q = &i;
          


        
5条回答
  •  清歌不尽
    2021-02-13 22:44

    The expression is the same as i=++i. The only tool that can detect it is your head. In C with power comes responsibility.

提交回复
热议问题