Assume such situation:

int a = (--t)*(t-2);
int b = (t/=a)+t;

In C and C++ this is undefined behaviour, as described here: Undefined behavior and sequence points

However, how does this situation look in:

  • JavaScript,
  • Java,
  • PHP...
  • C#
  • well, any other language which has compound operators?

I'm bugfixing a Javascript -> C++ port right now in which this got unnoticed in many places. I'd like to know how other languages generally handle this... Leaving the order undefined is somehow specific to C and C++, isn't it?

Edit
Report