This is probably a stupid question, but I am having a hard time finding something online about it.
I know that operator new can throw a bad_alloc exception if it fails to allocate memory, but what happens with local variable allocation?
Imagine I have a system where there is no more memory available and the program executes something like:
void do_something(){
int a = 0;
}
What will happen? how is the space necessary for "a" allocated? Can it throw?
I got the question from seeing code similar to this somewhere:
void do_something() noexcept {
// some local variables being allocated
}
It got me wondering the relation between no except and local memory allocation. Also, to make things a bit more confusing I saw this which got me wondering about when the memory allocation actually happens...