Why is my compiler reserving more space than required for a function stack frame?
问题 I have a function: void func(int a) { int x = a+2; } In the assembly code, in function prolog: push %ebp mov %esp, %ebp sub $0x10, %esp The code only needs to reserve space for x i.e. 4 bytes. But it is reserving 16 bytes. Why is that ? I have always seen it to reserve more space than required. My guess: it tends to store in 16 bytes. i.e. if I needed say 20 bytes, it will reserve 32 bytes, no matter what. 回答1: This highly depends on your architecture and compiler flags, so it is impossible