I decided to ask the question on this forum because I can not figure out why struct allocation makes the additional 16 bytes space on local function stack(third line at the second snippet).
Here is the c++ simple code and its corresponding assembly version
struct product {
int weight;
} ;
void test() {
product* p;
p=new product();
p->weight=1;
}
push rbp
mov rbp, rsp
sub rsp, 16
mov edi, 4
call operator new(unsigned long)
mov DWORD PTR [rax], 0
mov QWORD PTR [rbp-8], rax
mov rax, QWORD PTR [rbp-8]
mov DWORD PTR [rax], 1
nop
leave
ret