strange: k=(++i)+(++i)+(++i)???

T

tony_se

int i = 3;
int k=(++i)+(++i)+(++i);

after execution:
java: i=6, k=15
gcc: i=6, k=16
vc: i=6, k=18

why? it is strange!!
 
M

Mike Wahler

tony_se said:
int i = 3;
int k=(++i)+(++i)+(++i);

after execution:
java: i=6, k=15
gcc: i=6, k=16
vc: i=6, k=18

why? it is strange!!

Undefined behavior is often strange.
Did you check the FAQ?

-Mike
 
J

James Kanze

Undefined behavior is often strange.

Note that it's not undefined behavior in Java, and all
conformant Java implementations will give the same result.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,301
Messages
2,571,549
Members
48,295
Latest member
JayKillian
Top