some questions about gcc4

Cedric Roux
Tue Feb 23 16:19:00 GMT 2010

Alex wrote:
> I have only 1 int variable. My system is 32Bit. But why for 1 int
> variable compiler make sub esp,0x10 ?
> 1 int variable located in 4 bytes. What in another 12 ?

gcc man page says:
           Attempt to keep the stack boundary aligned to a 2 raised to num
           byte boundary.  If -mpreferred-stack-boundary is not specified, the
           default is 4 (16 bytes or 128 bits).

so do a gcc -mpreferred-stack-boundary=2 and you're done.

I think they set to 4 by default for performances' reasons, when you use SSE
data that likes to be aligned to 16 bytes. (Or maybe because the AMD64
ABI says the stack is 16 bytes aligned...) But let a gcc programmer answer
that if one has time to. :-) (And by the way I'm not sure of what I write,
so don't take it for the truth.)

More information about the Gcc-help mailing list