The best way to answer such questions (about the behavior of a particular compiler on a particular platform) is to look at the assembler. You can get gcc to reset your assembler by passing the -S flag (and the -fverbose-asm flag is good too). Performance
gcc -S -fverbose-asm file.c
gives file.s , which is a bit like (I deleted all the non-essential bits, and the bits in brackets are my notes):
CompareAddress:
( This question perfectly explains that [re]bp and [re]sp .)
The reason for the difference is negative: the stack grows down: i.e. if you push two things onto the stack, the one you push first will have a larger address, and a will be pushed to b .
The reason this is -4 , not -1 , is because the compiler decided that matching arguments with 4-byte boundaries is βbetterβ, possibly because a 32-bit / 64-bit processor deals with 4 bytes at a point in time is better than it processes single bytes.
(Also, looking at assembler shows an effect that has -mpreferred-stack-boundary : essentially means that the memory on the stack is allocated in chunks of different sizes.)
huon
source share