This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

allocation on the stack


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 
--



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]