In which versions of the C++ standard does “(i+=10)+=10” have undefined behaviour?
问题 In C++, does the following have undefined behaviour: int i = 0; (i+=10)+=10; There was some debate about this in the comments to my answer to What's the result of += in C and C++? The subtlety here is that the default response seems to be "yes", whereas it appears that the correct answer is "it depends on the version of the C++ standard". If it does depend on the version of the standard, please explain where it's UB and where it's not. 回答1: tl;dr : The sequence of the modifications and reads