As others have said, it'll be freed, and I don't really see how you could change the behavior. If you look at how an alloca
compiles on amd-64:
pushq %rbp
movq %rsp, %rbp
subq $144, %rsp
movq %rsp, %rax
addq $15, %rax
shrq $4, %rax
salq $4, %rax
leave
ret
You see
1) Alloca isn't actually a function call (because, as you said, it would have to handle the stack differently!)
2) Whatever alloca does to the stack pointer is just going to get clobbered at the end of the function when rbp
overwrites rsp
So could you get the behavior you ask about (without writing assembly)? That's a tricky question, and I don't know, but it seems like probably not.