Click here to Skip to main content
15,915,611 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralVC++ error in assembler Pin
anup_zade4-Jan-05 2:22
anup_zade4-Jan-05 2:22 
GeneralRe: VC++ error in assembler Pin
David Crow4-Jan-05 2:36
David Crow4-Jan-05 2:36 
Generali++ as referance Pin
Ranjish4-Jan-05 2:20
Ranjish4-Jan-05 2:20 
GeneralRe: i++ as referance Pin
BlackDice4-Jan-05 2:32
BlackDice4-Jan-05 2:32 
GeneralRe: i++ as referance Pin
Anonymous4-Jan-05 2:40
Anonymous4-Jan-05 2:40 
GeneralRe: i++ as referance Pin
Ryan Binns4-Jan-05 2:52
Ryan Binns4-Jan-05 2:52 
GeneralRe: i++ as referance Pin
Ranjish5-Jan-05 2:27
Ranjish5-Jan-05 2:27 
GeneralRe: i++ as referance Pin
Ryan Binns5-Jan-05 12:18
Ryan Binns5-Jan-05 12:18 
Ranjish wrote:
So in C/C++
Fun(++i, i++) first i++ will be evaluated and then ++i is evaluated and after that only Fun will be called.


No. The order of evaluation of function arguments is undefined. It is not specified by the standard, and the compilers can do whatever they like.

The results of modifying the same variable twice (or even three times) in a function call like you're doing is completely undefined. It's totally random. There is no way you can tell what is going to happen. The compiler doesn't even have to generate correct code for this case. In my opinion, the compiler should flag an error, because it's impossible to work out what should happen. Even in your case when you're expecting 13,11,11 the compiler could legally set every one of them to random numbers, because you're trying to do something undefined.

Basically, do not ever change the value of a variable twice in a single statement. The results are completely undefined, and could be anything.

Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

GeneralRe: i++ as referance Pin
Ryan Binns4-Jan-05 2:42
Ryan Binns4-Jan-05 2:42 
GeneralRe: i++ as referance Pin
BlackDice4-Jan-05 2:43
BlackDice4-Jan-05 2:43 
GeneralRe: i++ as referance Pin
Michael Dunn4-Jan-05 10:54
sitebuilderMichael Dunn4-Jan-05 10:54 
GeneralFolder Surveillance Pin
Anonymous4-Jan-05 2:13
Anonymous4-Jan-05 2:13 
GeneralRe: Folder Surveillance Pin
Maximilien4-Jan-05 2:26
Maximilien4-Jan-05 2:26 
GeneralRe: Folder Surveillance Pin
David Crow4-Jan-05 2:37
David Crow4-Jan-05 2:37 
GeneralRe: Folder Surveillance Pin
Jesse Evans4-Jan-05 11:10
Jesse Evans4-Jan-05 11:10 
QuestionHow to Search FrontPage Pin
Lavani4-Jan-05 1:56
Lavani4-Jan-05 1:56 
AnswerRe: How to Search FrontPage Pin
David Crow4-Jan-05 2:40
David Crow4-Jan-05 2:40 
GeneralRe: How to Search FrontPage Pin
Anonymous4-Jan-05 18:08
Anonymous4-Jan-05 18:08 
GeneralRe: How to Search FrontPage Pin
lavanii4-Jan-05 18:14
susslavanii4-Jan-05 18:14 
GeneralRe: How to Search FrontPage Pin
David Crow5-Jan-05 2:26
David Crow5-Jan-05 2:26 
QuestionProfile tool for VC++6 ? Pin
GuimaSun4-Jan-05 1:44
GuimaSun4-Jan-05 1:44 
AnswerRe: Profile tool for VC++6 ? Pin
Blake Miller4-Jan-05 8:47
Blake Miller4-Jan-05 8:47 
GeneralProblem with MessageBox() Pin
realloc4-Jan-05 1:24
realloc4-Jan-05 1:24 
GeneralRe: Problem with MessageBox() Pin
Blake Miller4-Jan-05 8:51
Blake Miller4-Jan-05 8:51 
GeneralRe: Problem with MessageBox() Pin
realloc4-Jan-05 11:51
realloc4-Jan-05 11:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.