Let's consider a scenario like this:
int a = (--t)*(t-2);
int b = (t/=a)+t;
While in C and C++, this leads to undefined behavior, as explained in this article: Undefined behavior and sequence points
But how is this situation handled in:
- JavaScript,
- Java,
- PHP...
- C#
- or any other language that uses compound operators?
I'm currently fixing a bug in a Javascript -> C++ conversion project where this issue was overlooked in multiple places. It would be interesting to know how other languages generally address this... Is leaving the order undefined a specific feature of C and C++?