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); }
Confirmed, very much related to PR 19774.
Fixed by tree-ssa's EH lowering and builtin_alloca handling.