gcc is allocating more stack space than needed. It seems to be bug similar to bug 9624.
C test code. ------------ 1 #include <stdio.h> 2 3 void function1() { 4 char a; 5 } 6 7 int main() { 8 function1(); 9 } Assembly Output ---------------- 1 .file "test1.c" 2 .text 3 .globl function1 4 .type function1, @function 5 function1: 6 pushl %ebp 7 movl %esp, %ebp 8 subl $16, %esp <----- 16 bytes for a char?? 9 leave 10 ret 11 .size function1, .-function1 12 .globl main 13 .type main, @function 14 main: 15 leal 4(%esp), %ecx 16 andl $-16, %esp 17 pushl -4(%ecx) 18 pushl %ebp 19 movl %esp, %ebp 20 pushl %ecx 21 call function1 22 popl %ecx 23 popl %ebp 24 leal -4(%ecx), %esp 25 ret 26 .size main, .-main 27 .ident "GCC: (GNU) 4.2.4 (Ubuntu 4.2.4-1ubuntu3)" 28 .section .note.GNU-stack,"",@progbits gcc -v output ------------- Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3) -- Summary: Stack allocation in the assembly output is more than needed. Product: gcc Version: 4.2.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: nascent dot mind at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39428