This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
allocation on the stack
- To: <gcc at gcc dot gnu dot org>
- Subject: allocation on the stack
- From: "Thomas van Gulick" <list at utumno dot student dot utwente dot nl>
- Date: Tue, 28 Sep 1999 02:21:22 +0200
Is there any way to recover from the impossibility of allocating
some space on stack which is actually not available?
Take for example the following code:
void function(void) {
char buffer[1*1024*1024*1024];
cout << "function()\n";
}
void main(void) {
function();
}
On my system, there is not enough memory to store the amount
of memory required inside the function().
Here the program corrupts the stack and segfaults
program segfaults, never to return from function().
Is there any way to catch this problem and continue running,
like the bad_alloc exception with the new operator?
(I'm using gcc 2.95.1)
Thomas
--