On both gcc (GCC) 3.3.5 (propolice) and gcc.exe (GCC) 3.4.2 (mingw-special) the following code does not work properly.
Its output should be test1<nl>test2<nl>test3<nl>, but the 3rd output gets malformed. It seems to me the stack is unwindded too far by sjlj-eh at the entrance of catch block and the region obtained by alloca() is destroyed. <test.cpp>--------------- #include "malloc.h" #include "string.h" #include "stdio.h" static void foo2(); int main(int, char**) { int a=0; a=a+1; char *b=(char *)alloca(10); strcpy(b,"test"); printf("%s%d\n", b, a); try { a++; printf("%s%d\n", b, a); foo2(); } catch(...){ a++; printf("%s%d\n", b, a); } return 0; } static void foo2() { int i=1; throw(i); } -- Summary: SJLJ exception handling fails in function using alloca() Product: gcc Version: 3.4.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: t_ono at hkfreak dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25266