Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Pre vs Post Incrementing variables

by SavannahLion (Pilgrim)
on Sep 12, 2010 at 14:19 UTC ( [id://859852] : note . print w/replies, xml ) Need Help??


in reply to Re: Pre vs Post Incrementing variables
in thread Pre vs Post Incrementing variables

Well... In the samples I gave above, the C++ IDE I used was MS Visual Studio 8 (or 2005, whatever it wants to call itself now) which gave 2 2 (or 3 3 3 in your sample) in the default Debug mode. So I guess virtually add it to the list there.

It is, however, useful to know this about the compilers. I know the C family compilers have their own idiosyncrasies, I guess I'll put this on the pile things to note.

Replies are listed 'Best First'.
Re^3: Pre vs Post Incrementing variables
by cdarke (Prior) on Sep 13, 2010 at 08:18 UTC
    I have noticed differences in later .Net versions of Visual Studio. I did not have them to hand when I wrote the node, and didn't want to guess. It could be that there is optimisation even in Debug. Check the project settings?

    So far as I can tell though, the order of execution (in C) of parameters is not defined. The reason why VS 6.0 (Debug) executed them from right to left was because that is the order of the C calling convention, __cdecl.
      cdecl controls the order in which the arguments are placed on the stack, not the order in which they are evaluated. While it tends to suggest a certain evaluation order, one cannot rely on it.