https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106949
--- Comment #3 from Ian Lance Taylor <ian at airs dot com> --- I don't think your attached patch is going to work. The code assumes that it is running within a stack segment. You can't just add a stack segment without changing the stack pointer. But something like your suggestion might work. If the function is going to call __morestack_allocate_stack_space, then at the start of the function call a new function __morestack_allocating_stack_space. That function can return a pointer. The __morestack_allocate_stack_space function can add its allocations to a list at that pointer. At the end of the function call another new function that releases the allocated space. Some work will be required to make sure that the space gets released if an exception is thrown.