When analyzing the binary code generated by g++ 5.2.0, I found that the compiler frequently allocates memory that seems not used by any program elements. Below is an example.
The source code is
void
cxx_pretty_printer::declarator (tree t)
{
this->direct_declarator (t); // A virtual function call
}
and the generated binary
0x8427ce8 _ZN18cxx_pretty_printer10declaratorEP9tree_node:
0x8427ce8 push %ebp
0x8427ce9 mov %esp, %ebp
0x8427ceb sub $0x8, %esp
0x8427cee mov 0x8(%ebp), %eax
0x8427cf1 mov 0x0(%eax), %eax
0x8427cf3 add $0x4c, %eax
0x8427cf6 mov 0x0(%eax), %eax
0x8427cf8 sub $0x8, %esp
0x8427cfb pushl 0xc(%ebp)
0x8427cfe pushl 0x8(%ebp)
0x8427d01 call *0x0(%eax,0)
0x8427d03 add $0x10, %esp
0x8427d06 nop
0x8427d07 leave
0x8427d08 ret
I don't quite understand why the code at 0x8427ceb and 0x8427cf8 should exist. The compiler decreases the stack register, which seems to me that it is allocating some space on the stack. However, this space is never used by anything.
Is there any particular reason that makes g++ do this? The options I used are
-O2 -fno-exceptions -fno-rtti -fasynchronous-unwind-tables