473,326 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

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!!

Apr 7 '07 #1
5 1233
"tony_se" <to*************@gmail.comwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com
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!!
This is about the 10,000th time this has been asked. The behaviour in C++ is
undefined. Anything can happen.

http://www.parashift.com/c++-faq-lit...html#faq-39.15
--
John Carson
Apr 7 '07 #2

"tony_se" <to*************@gmail.comwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
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
Apr 7 '07 #3
On Apr 7, 6:25 am, "Mike Wahler" <mkwah...@mkwahler.netwrote:
"tony_se" <tonywinslow1...@gmail.comwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
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.
Note that it's not undefined behavior in Java, and all
conformant Java implementations will give the same result.

--
James Kanze (Gabi Software) email: ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Apr 7 '07 #4
Thank you all!
Can you tell me where to find FAQ?

Apr 7 '07 #5
tony_se wrote:
Thank you all!
Can you tell me where to find FAQ?
John Carson gave it to you in his reply,
but here it is again:

http://www.parashift.com/c++-faq-lit...html#faq-39.15
Apr 7 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Arthur | last post by:
I've come across some strange xml, that I need to deal with, it looks like this:- <root> <foo attr="1">Some random strange text. <bar attr="2">blar</bar> <bar attr="3">blar blar</bar> <bar...
2
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
2
by: Olaf | last post by:
I have a frameset page witch contains the myFuc() function. The function is accessed from a page in one of the frames in the frameset. An example is shown below. <input...
7
by: M O J O | last post by:
Hi, I'm developing a asp.net application and ran into a strange css problem. I want all my links to have a dashed underline and when they are hovered, it must change to a solid line. Sounds...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
0
by: unknown | last post by:
Hi, I am developing an online book store with shopping cart. My shopping cart is represented as a Xml server control and I am using an XSLT to render it at the client side. I am using an...
0
by: Kris Vanherck | last post by:
yesterday i started getting this strange error when i try to run my asp.net project: Compiler Error Message: CS0006: Metadata file 'c:\winnt\microsoft.net\framework\v1.1.4322\temporary asp.net...
11
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating...
20
by: SpreadTooThin | last post by:
I have a list and I need to do a custom sort on it... for example: a = #Although not necessarily in order def cmp(i,j): #to be defined in this thread. a.sort(cmp) print a
14
by: blumen | last post by:
Hi all, I'm a newbie in VB.Net Programming.. Hope that some of you can help me to solve this.. I'm working out to read,parse and save textfile into SQL Server. The textfile contains thousands...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.