octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

chaining compound assignment results in undefined behavior


From: Hossein Sajjadi
Subject: chaining compound assignment results in undefined behavior
Date: Fri, 6 Jun 2014 17:20:08 +0330

Hi

There is a problem with chaining compound assignment.
For example the expression a=1;a+=a+=4 will result 10.
I think such a behavior is borrowed from C language but this behavior
is known as "undefined behavior".
 This issue have been resolven in Java.
 Java language guarantees that the operands of operators appear
to be evaluated in a specific evaluation order , namely, from left to
right. §15.7
Other specifications about evaluation of expressions are in
"The Java® Language Specification"

 also this approach is followed by c# language
 so result of above expression in Java is 6



reply via email to

[Prev in Thread] Current Thread [Next in Thread]