Handling pre-increment and post-increment in GCC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello All,
   I am trying to understand how GCC handles this piece of code, but
unfortunately the behaviour is different on different architectures
=====================================================
#include < stdio.h>

int main(void)
{
   int i = 2;

   return printf("Post increment : %d, Pre increment : %d\n", i++, ++i);
}
=====================================================

On Powerpc (Powerbook G4) this gives
%%%%%%%%%%%%%%%%%%%
Post increment : 2, Pre increment : 4

however on Intel machines this gives
%%%%%%%%%%%%%%%%%%%
Post increment : 4, Pre increment : 2

On MIPS & ARM, the behaviour is different as well.

Can anyone please explain the same?? Also can anyone please point me
the direction where I should look in the GCC Internals for a clear
understanding??

Regards,
/Manjunath B.S.



--
No fear, no guilt, no shame, this is all that takes to be a man!!

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux