MSVC 19.33 disagrees with GCC >= 4.8.1 and Clang >= 3.4.1 on the outcome of the following code:
int x{0};
x = x++; // 1 with MSVC, 0 with GCC and Clang
I know the code is silly. It is auto-generated and it's not the point. I wonder how the post-increment is defined by the standard such that MSVC differs in its implementation.
I would expect an implementation like this:
int operator++( int& i )
{
int old{ i };
++i;
return old;
}
With this implementation the increment happens first and then the old value is returned by the function. But MSVC does something else. What would be a possible implementation to reproduce this behaviour?