How do languages handle side effects of compound operators?
Posted
by
Kos
on Stack Overflow
See other posts from Stack Overflow
or by Kos
Published on 2011-02-14T13:56:16Z
Indexed on
2011/02/14
15:25 UTC
Read the original article
Hit count: 326
Hello,
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?
© Stack Overflow or respective owner