What is the result of i == (i = 2)?
up vote
22
down vote
favorite
Run the following code:
// In Java, output #####
public static void main(String args) {
int i = 1;
if(i == (i = 2)) {
System.out.println("@@@@@");
} else {
System.out.println("#####");
}
}
But:
// In C, output @@@@@,I did test on Clion(GCC 7.3) and Visual Studio 2017
int main(int argc, char *argv) {
int i = 1;
if(i == (i = 2)) {
printf("@@@@@");
} else {
printf("#####");
}
return 0;
}
The motivation for asking this question comes from the following code:
// The code is from the JDK 11 - java.util.concurrent.atomic.AtomicInteger
// I am curious about the behavior of the variable prev.
public final int getAndUpdate(IntUnaryOperator updateFunction) {
int prev = get(), next = 0;
for (boolean haveNext = false;;) {
if (!haveNext)
next = updateFunction.applyAsInt(prev);
if (weakCompareAndSetVolatile(prev, next))
return prev;
haveNext = (prev == (prev = get()));
}
}
So, how to explain the above two different execution modes?
java c language-lawyer variable-assignment side-effects
|
show 4 more comments
up vote
22
down vote
favorite
Run the following code:
// In Java, output #####
public static void main(String args) {
int i = 1;
if(i == (i = 2)) {
System.out.println("@@@@@");
} else {
System.out.println("#####");
}
}
But:
// In C, output @@@@@,I did test on Clion(GCC 7.3) and Visual Studio 2017
int main(int argc, char *argv) {
int i = 1;
if(i == (i = 2)) {
printf("@@@@@");
} else {
printf("#####");
}
return 0;
}
The motivation for asking this question comes from the following code:
// The code is from the JDK 11 - java.util.concurrent.atomic.AtomicInteger
// I am curious about the behavior of the variable prev.
public final int getAndUpdate(IntUnaryOperator updateFunction) {
int prev = get(), next = 0;
for (boolean haveNext = false;;) {
if (!haveNext)
next = updateFunction.applyAsInt(prev);
if (weakCompareAndSetVolatile(prev, next))
return prev;
haveNext = (prev == (prev = get()));
}
}
So, how to explain the above two different execution modes?
java c language-lawyer variable-assignment side-effects
11
One explains the two different execution modes by first noting that those are two entirely different languages. They happen to share some syntax, but that's where the similarities end.
– StoryTeller
yesterday
3
The result is : a messy code. Better not imitate this unless you are running for a java obfuscation contest.
– Tristan
yesterday
3
Possible duplicate of Logic differences in C and Java
– user202729
yesterday
(although the specific operator used (==, ++, =, etc.) are different, the answer (it's well defined in Java, sequence point --> undefined behavior) is the same)
– user202729
yesterday
1
Undefined behavior and sequence points
– phuclv
yesterday
|
show 4 more comments
up vote
22
down vote
favorite
up vote
22
down vote
favorite
Run the following code:
// In Java, output #####
public static void main(String args) {
int i = 1;
if(i == (i = 2)) {
System.out.println("@@@@@");
} else {
System.out.println("#####");
}
}
But:
// In C, output @@@@@,I did test on Clion(GCC 7.3) and Visual Studio 2017
int main(int argc, char *argv) {
int i = 1;
if(i == (i = 2)) {
printf("@@@@@");
} else {
printf("#####");
}
return 0;
}
The motivation for asking this question comes from the following code:
// The code is from the JDK 11 - java.util.concurrent.atomic.AtomicInteger
// I am curious about the behavior of the variable prev.
public final int getAndUpdate(IntUnaryOperator updateFunction) {
int prev = get(), next = 0;
for (boolean haveNext = false;;) {
if (!haveNext)
next = updateFunction.applyAsInt(prev);
if (weakCompareAndSetVolatile(prev, next))
return prev;
haveNext = (prev == (prev = get()));
}
}
So, how to explain the above two different execution modes?
java c language-lawyer variable-assignment side-effects
Run the following code:
// In Java, output #####
public static void main(String args) {
int i = 1;
if(i == (i = 2)) {
System.out.println("@@@@@");
} else {
System.out.println("#####");
}
}
But:
// In C, output @@@@@,I did test on Clion(GCC 7.3) and Visual Studio 2017
int main(int argc, char *argv) {
int i = 1;
if(i == (i = 2)) {
printf("@@@@@");
} else {
printf("#####");
}
return 0;
}
The motivation for asking this question comes from the following code:
// The code is from the JDK 11 - java.util.concurrent.atomic.AtomicInteger
// I am curious about the behavior of the variable prev.
public final int getAndUpdate(IntUnaryOperator updateFunction) {
int prev = get(), next = 0;
for (boolean haveNext = false;;) {
if (!haveNext)
next = updateFunction.applyAsInt(prev);
if (weakCompareAndSetVolatile(prev, next))
return prev;
haveNext = (prev == (prev = get()));
}
}
So, how to explain the above two different execution modes?
java c language-lawyer variable-assignment side-effects
java c language-lawyer variable-assignment side-effects
edited 23 hours ago
Solomon Ucko
606718
606718
asked yesterday
kangjianwei
351210
351210
11
One explains the two different execution modes by first noting that those are two entirely different languages. They happen to share some syntax, but that's where the similarities end.
– StoryTeller
yesterday
3
The result is : a messy code. Better not imitate this unless you are running for a java obfuscation contest.
– Tristan
yesterday
3
Possible duplicate of Logic differences in C and Java
– user202729
yesterday
(although the specific operator used (==, ++, =, etc.) are different, the answer (it's well defined in Java, sequence point --> undefined behavior) is the same)
– user202729
yesterday
1
Undefined behavior and sequence points
– phuclv
yesterday
|
show 4 more comments
11
One explains the two different execution modes by first noting that those are two entirely different languages. They happen to share some syntax, but that's where the similarities end.
– StoryTeller
yesterday
3
The result is : a messy code. Better not imitate this unless you are running for a java obfuscation contest.
– Tristan
yesterday
3
Possible duplicate of Logic differences in C and Java
– user202729
yesterday
(although the specific operator used (==, ++, =, etc.) are different, the answer (it's well defined in Java, sequence point --> undefined behavior) is the same)
– user202729
yesterday
1
Undefined behavior and sequence points
– phuclv
yesterday
11
11
One explains the two different execution modes by first noting that those are two entirely different languages. They happen to share some syntax, but that's where the similarities end.
– StoryTeller
yesterday
One explains the two different execution modes by first noting that those are two entirely different languages. They happen to share some syntax, but that's where the similarities end.
– StoryTeller
yesterday
3
3
The result is : a messy code. Better not imitate this unless you are running for a java obfuscation contest.
– Tristan
yesterday
The result is : a messy code. Better not imitate this unless you are running for a java obfuscation contest.
– Tristan
yesterday
3
3
Possible duplicate of Logic differences in C and Java
– user202729
yesterday
Possible duplicate of Logic differences in C and Java
– user202729
yesterday
(although the specific operator used (==, ++, =, etc.) are different, the answer (it's well defined in Java, sequence point --> undefined behavior) is the same)
– user202729
yesterday
(although the specific operator used (==, ++, =, etc.) are different, the answer (it's well defined in Java, sequence point --> undefined behavior) is the same)
– user202729
yesterday
1
1
Undefined behavior and sequence points
– phuclv
yesterday
Undefined behavior and sequence points
– phuclv
yesterday
|
show 4 more comments
3 Answers
3
active
oldest
votes
up vote
41
down vote
The behaviour of a C program that executes the expression i == (i = 2)
is undefined.
It comes from C11 6.5p22:
- If a side effect on a scalar object is unsequenced relative to either a different side effect on the same scalar object or a value computation using the value of the same scalar object, the behavior is undefined. If there are multiple allowable orderings of the subexpressions of an expression, the behavior is undefined if such an unsequenced side effect occurs in any of the orderings.84)
The i
on the left-hand side of ==
is a value computation on the value of scalar object i
and the right-hand side i = 2
has a side effect of assigning the value 2
to i
. The LHS and RHS of ==
are unsequenced w.r.t. each other. Hence the entire program is meaningless in C.
Compile with gcc -Wall
and GCC will spit out:
unsequenced.c:5:16: warning: operation on ‘i’ may be undefined [-Wsequence-point]
if(i == (i = 2)) {
~~~^~~~
Unlike C, Java guarantees the evaluation order for operands (left-to-right), therefore
haveNext = (prev == (prev = get()));
is correct in Java. The value of LHS is determined strictly before the evaluation of the side effect on the RHS occurs.
In C you have to write this as something like
newPrev = get();
haveNext = (prev == newPrev);
prev = newPrev;
Why isi
on the LHS a value computation? Is it specified somewhere in the Standard?
– Some Name
yesterday
1
@SomeName of course it is specified somewhere in the standard. :D
– Antti Haapala
yesterday
So how about reference? :) The only I could find was thevalue
term defined in 3.19, but novalue computation
defined there.
– Some Name
yesterday
@SomeName you need to infer it from way too many places in the prose :/ the footnote 84 however can be used as a shortcut. Ifi
there was not a value of an expression thena[i++] = i;
would be defined. Footnotes are not normative though.
– Antti Haapala
yesterday
1
@SomeName 5.1.2.3p2 says "value computation of lvalue expression", which is a case here,i
is an lvalue and its value need to be computed, as it is not an operand. 6.3.2.1p2 says "converted to the value stored in the designated object", but this is the one referred to by 5.1.2.3p2
– Antti Haapala
yesterday
|
show 6 more comments
up vote
12
down vote
The Java Language Specification (§15.7) states:
The Java programming language guarantees that the operands of operators appear
to be evaluated in a specific evaluation order, namely, from left to right.
The specification (§15.21.1) also states that:
The value produced by the
==
operator istrue
if the value of the left-hand
operand is equal to the value of the right-hand operand; otherwise, the result is
false
.
Therefore in Java, the if-statement at runtime would look like the following, which obviously evaluates to false
:
if (1 == 2) {
}
In C, it is simply undefined (see Antti's answer).
add a comment |
up vote
3
down vote
In C, the behavior of i == (i = 2)
is undefined because it attempts to both update an object and use that object’s value in a computation without an intervening sequence point. The result will vary based on the compiler, compiler settings, even the surrounding code.
what about Java?
– The Great Duck
23 hours ago
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
41
down vote
The behaviour of a C program that executes the expression i == (i = 2)
is undefined.
It comes from C11 6.5p22:
- If a side effect on a scalar object is unsequenced relative to either a different side effect on the same scalar object or a value computation using the value of the same scalar object, the behavior is undefined. If there are multiple allowable orderings of the subexpressions of an expression, the behavior is undefined if such an unsequenced side effect occurs in any of the orderings.84)
The i
on the left-hand side of ==
is a value computation on the value of scalar object i
and the right-hand side i = 2
has a side effect of assigning the value 2
to i
. The LHS and RHS of ==
are unsequenced w.r.t. each other. Hence the entire program is meaningless in C.
Compile with gcc -Wall
and GCC will spit out:
unsequenced.c:5:16: warning: operation on ‘i’ may be undefined [-Wsequence-point]
if(i == (i = 2)) {
~~~^~~~
Unlike C, Java guarantees the evaluation order for operands (left-to-right), therefore
haveNext = (prev == (prev = get()));
is correct in Java. The value of LHS is determined strictly before the evaluation of the side effect on the RHS occurs.
In C you have to write this as something like
newPrev = get();
haveNext = (prev == newPrev);
prev = newPrev;
Why isi
on the LHS a value computation? Is it specified somewhere in the Standard?
– Some Name
yesterday
1
@SomeName of course it is specified somewhere in the standard. :D
– Antti Haapala
yesterday
So how about reference? :) The only I could find was thevalue
term defined in 3.19, but novalue computation
defined there.
– Some Name
yesterday
@SomeName you need to infer it from way too many places in the prose :/ the footnote 84 however can be used as a shortcut. Ifi
there was not a value of an expression thena[i++] = i;
would be defined. Footnotes are not normative though.
– Antti Haapala
yesterday
1
@SomeName 5.1.2.3p2 says "value computation of lvalue expression", which is a case here,i
is an lvalue and its value need to be computed, as it is not an operand. 6.3.2.1p2 says "converted to the value stored in the designated object", but this is the one referred to by 5.1.2.3p2
– Antti Haapala
yesterday
|
show 6 more comments
up vote
41
down vote
The behaviour of a C program that executes the expression i == (i = 2)
is undefined.
It comes from C11 6.5p22:
- If a side effect on a scalar object is unsequenced relative to either a different side effect on the same scalar object or a value computation using the value of the same scalar object, the behavior is undefined. If there are multiple allowable orderings of the subexpressions of an expression, the behavior is undefined if such an unsequenced side effect occurs in any of the orderings.84)
The i
on the left-hand side of ==
is a value computation on the value of scalar object i
and the right-hand side i = 2
has a side effect of assigning the value 2
to i
. The LHS and RHS of ==
are unsequenced w.r.t. each other. Hence the entire program is meaningless in C.
Compile with gcc -Wall
and GCC will spit out:
unsequenced.c:5:16: warning: operation on ‘i’ may be undefined [-Wsequence-point]
if(i == (i = 2)) {
~~~^~~~
Unlike C, Java guarantees the evaluation order for operands (left-to-right), therefore
haveNext = (prev == (prev = get()));
is correct in Java. The value of LHS is determined strictly before the evaluation of the side effect on the RHS occurs.
In C you have to write this as something like
newPrev = get();
haveNext = (prev == newPrev);
prev = newPrev;
Why isi
on the LHS a value computation? Is it specified somewhere in the Standard?
– Some Name
yesterday
1
@SomeName of course it is specified somewhere in the standard. :D
– Antti Haapala
yesterday
So how about reference? :) The only I could find was thevalue
term defined in 3.19, but novalue computation
defined there.
– Some Name
yesterday
@SomeName you need to infer it from way too many places in the prose :/ the footnote 84 however can be used as a shortcut. Ifi
there was not a value of an expression thena[i++] = i;
would be defined. Footnotes are not normative though.
– Antti Haapala
yesterday
1
@SomeName 5.1.2.3p2 says "value computation of lvalue expression", which is a case here,i
is an lvalue and its value need to be computed, as it is not an operand. 6.3.2.1p2 says "converted to the value stored in the designated object", but this is the one referred to by 5.1.2.3p2
– Antti Haapala
yesterday
|
show 6 more comments
up vote
41
down vote
up vote
41
down vote
The behaviour of a C program that executes the expression i == (i = 2)
is undefined.
It comes from C11 6.5p22:
- If a side effect on a scalar object is unsequenced relative to either a different side effect on the same scalar object or a value computation using the value of the same scalar object, the behavior is undefined. If there are multiple allowable orderings of the subexpressions of an expression, the behavior is undefined if such an unsequenced side effect occurs in any of the orderings.84)
The i
on the left-hand side of ==
is a value computation on the value of scalar object i
and the right-hand side i = 2
has a side effect of assigning the value 2
to i
. The LHS and RHS of ==
are unsequenced w.r.t. each other. Hence the entire program is meaningless in C.
Compile with gcc -Wall
and GCC will spit out:
unsequenced.c:5:16: warning: operation on ‘i’ may be undefined [-Wsequence-point]
if(i == (i = 2)) {
~~~^~~~
Unlike C, Java guarantees the evaluation order for operands (left-to-right), therefore
haveNext = (prev == (prev = get()));
is correct in Java. The value of LHS is determined strictly before the evaluation of the side effect on the RHS occurs.
In C you have to write this as something like
newPrev = get();
haveNext = (prev == newPrev);
prev = newPrev;
The behaviour of a C program that executes the expression i == (i = 2)
is undefined.
It comes from C11 6.5p22:
- If a side effect on a scalar object is unsequenced relative to either a different side effect on the same scalar object or a value computation using the value of the same scalar object, the behavior is undefined. If there are multiple allowable orderings of the subexpressions of an expression, the behavior is undefined if such an unsequenced side effect occurs in any of the orderings.84)
The i
on the left-hand side of ==
is a value computation on the value of scalar object i
and the right-hand side i = 2
has a side effect of assigning the value 2
to i
. The LHS and RHS of ==
are unsequenced w.r.t. each other. Hence the entire program is meaningless in C.
Compile with gcc -Wall
and GCC will spit out:
unsequenced.c:5:16: warning: operation on ‘i’ may be undefined [-Wsequence-point]
if(i == (i = 2)) {
~~~^~~~
Unlike C, Java guarantees the evaluation order for operands (left-to-right), therefore
haveNext = (prev == (prev = get()));
is correct in Java. The value of LHS is determined strictly before the evaluation of the side effect on the RHS occurs.
In C you have to write this as something like
newPrev = get();
haveNext = (prev == newPrev);
prev = newPrev;
edited yesterday
answered yesterday
Antti Haapala
79k16148191
79k16148191
Why isi
on the LHS a value computation? Is it specified somewhere in the Standard?
– Some Name
yesterday
1
@SomeName of course it is specified somewhere in the standard. :D
– Antti Haapala
yesterday
So how about reference? :) The only I could find was thevalue
term defined in 3.19, but novalue computation
defined there.
– Some Name
yesterday
@SomeName you need to infer it from way too many places in the prose :/ the footnote 84 however can be used as a shortcut. Ifi
there was not a value of an expression thena[i++] = i;
would be defined. Footnotes are not normative though.
– Antti Haapala
yesterday
1
@SomeName 5.1.2.3p2 says "value computation of lvalue expression", which is a case here,i
is an lvalue and its value need to be computed, as it is not an operand. 6.3.2.1p2 says "converted to the value stored in the designated object", but this is the one referred to by 5.1.2.3p2
– Antti Haapala
yesterday
|
show 6 more comments
Why isi
on the LHS a value computation? Is it specified somewhere in the Standard?
– Some Name
yesterday
1
@SomeName of course it is specified somewhere in the standard. :D
– Antti Haapala
yesterday
So how about reference? :) The only I could find was thevalue
term defined in 3.19, but novalue computation
defined there.
– Some Name
yesterday
@SomeName you need to infer it from way too many places in the prose :/ the footnote 84 however can be used as a shortcut. Ifi
there was not a value of an expression thena[i++] = i;
would be defined. Footnotes are not normative though.
– Antti Haapala
yesterday
1
@SomeName 5.1.2.3p2 says "value computation of lvalue expression", which is a case here,i
is an lvalue and its value need to be computed, as it is not an operand. 6.3.2.1p2 says "converted to the value stored in the designated object", but this is the one referred to by 5.1.2.3p2
– Antti Haapala
yesterday
Why is
i
on the LHS a value computation? Is it specified somewhere in the Standard?– Some Name
yesterday
Why is
i
on the LHS a value computation? Is it specified somewhere in the Standard?– Some Name
yesterday
1
1
@SomeName of course it is specified somewhere in the standard. :D
– Antti Haapala
yesterday
@SomeName of course it is specified somewhere in the standard. :D
– Antti Haapala
yesterday
So how about reference? :) The only I could find was the
value
term defined in 3.19, but no value computation
defined there.– Some Name
yesterday
So how about reference? :) The only I could find was the
value
term defined in 3.19, but no value computation
defined there.– Some Name
yesterday
@SomeName you need to infer it from way too many places in the prose :/ the footnote 84 however can be used as a shortcut. If
i
there was not a value of an expression then a[i++] = i;
would be defined. Footnotes are not normative though.– Antti Haapala
yesterday
@SomeName you need to infer it from way too many places in the prose :/ the footnote 84 however can be used as a shortcut. If
i
there was not a value of an expression then a[i++] = i;
would be defined. Footnotes are not normative though.– Antti Haapala
yesterday
1
1
@SomeName 5.1.2.3p2 says "value computation of lvalue expression", which is a case here,
i
is an lvalue and its value need to be computed, as it is not an operand. 6.3.2.1p2 says "converted to the value stored in the designated object", but this is the one referred to by 5.1.2.3p2– Antti Haapala
yesterday
@SomeName 5.1.2.3p2 says "value computation of lvalue expression", which is a case here,
i
is an lvalue and its value need to be computed, as it is not an operand. 6.3.2.1p2 says "converted to the value stored in the designated object", but this is the one referred to by 5.1.2.3p2– Antti Haapala
yesterday
|
show 6 more comments
up vote
12
down vote
The Java Language Specification (§15.7) states:
The Java programming language guarantees that the operands of operators appear
to be evaluated in a specific evaluation order, namely, from left to right.
The specification (§15.21.1) also states that:
The value produced by the
==
operator istrue
if the value of the left-hand
operand is equal to the value of the right-hand operand; otherwise, the result is
false
.
Therefore in Java, the if-statement at runtime would look like the following, which obviously evaluates to false
:
if (1 == 2) {
}
In C, it is simply undefined (see Antti's answer).
add a comment |
up vote
12
down vote
The Java Language Specification (§15.7) states:
The Java programming language guarantees that the operands of operators appear
to be evaluated in a specific evaluation order, namely, from left to right.
The specification (§15.21.1) also states that:
The value produced by the
==
operator istrue
if the value of the left-hand
operand is equal to the value of the right-hand operand; otherwise, the result is
false
.
Therefore in Java, the if-statement at runtime would look like the following, which obviously evaluates to false
:
if (1 == 2) {
}
In C, it is simply undefined (see Antti's answer).
add a comment |
up vote
12
down vote
up vote
12
down vote
The Java Language Specification (§15.7) states:
The Java programming language guarantees that the operands of operators appear
to be evaluated in a specific evaluation order, namely, from left to right.
The specification (§15.21.1) also states that:
The value produced by the
==
operator istrue
if the value of the left-hand
operand is equal to the value of the right-hand operand; otherwise, the result is
false
.
Therefore in Java, the if-statement at runtime would look like the following, which obviously evaluates to false
:
if (1 == 2) {
}
In C, it is simply undefined (see Antti's answer).
The Java Language Specification (§15.7) states:
The Java programming language guarantees that the operands of operators appear
to be evaluated in a specific evaluation order, namely, from left to right.
The specification (§15.21.1) also states that:
The value produced by the
==
operator istrue
if the value of the left-hand
operand is equal to the value of the right-hand operand; otherwise, the result is
false
.
Therefore in Java, the if-statement at runtime would look like the following, which obviously evaluates to false
:
if (1 == 2) {
}
In C, it is simply undefined (see Antti's answer).
edited yesterday
answered yesterday
Jacob G.
14.8k51962
14.8k51962
add a comment |
add a comment |
up vote
3
down vote
In C, the behavior of i == (i = 2)
is undefined because it attempts to both update an object and use that object’s value in a computation without an intervening sequence point. The result will vary based on the compiler, compiler settings, even the surrounding code.
what about Java?
– The Great Duck
23 hours ago
add a comment |
up vote
3
down vote
In C, the behavior of i == (i = 2)
is undefined because it attempts to both update an object and use that object’s value in a computation without an intervening sequence point. The result will vary based on the compiler, compiler settings, even the surrounding code.
what about Java?
– The Great Duck
23 hours ago
add a comment |
up vote
3
down vote
up vote
3
down vote
In C, the behavior of i == (i = 2)
is undefined because it attempts to both update an object and use that object’s value in a computation without an intervening sequence point. The result will vary based on the compiler, compiler settings, even the surrounding code.
In C, the behavior of i == (i = 2)
is undefined because it attempts to both update an object and use that object’s value in a computation without an intervening sequence point. The result will vary based on the compiler, compiler settings, even the surrounding code.
answered yesterday
John Bode
80.6k1375149
80.6k1375149
what about Java?
– The Great Duck
23 hours ago
add a comment |
what about Java?
– The Great Duck
23 hours ago
what about Java?
– The Great Duck
23 hours ago
what about Java?
– The Great Duck
23 hours ago
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53577739%2fwhat-is-the-result-of-i-i-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
11
One explains the two different execution modes by first noting that those are two entirely different languages. They happen to share some syntax, but that's where the similarities end.
– StoryTeller
yesterday
3
The result is : a messy code. Better not imitate this unless you are running for a java obfuscation contest.
– Tristan
yesterday
3
Possible duplicate of Logic differences in C and Java
– user202729
yesterday
(although the specific operator used (==, ++, =, etc.) are different, the answer (it's well defined in Java, sequence point --> undefined behavior) is the same)
– user202729
yesterday
1
Undefined behavior and sequence points
– phuclv
yesterday