What is x after “x = x++”?

后端 未结 17 1356
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-21 06:26

What happens (behind the curtains) when this is executed?

int x = 7;
x = x++;

That is, when a variable is post incremented and assigned to

17条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-21 06:38

    int x = 7;
    x = x++;
    

    It has undefined behaviour in C and for Java see this answer. It depends on compiler what happens.

提交回复
热议问题