While strolling through the dark corners of the testsuite, as one does :-), I discovered the gcc.c-torture/execute/nestfunct-5.c testcase.
How can goto's out of a nested fn to the containing fn possibly work? Here foo() & bar() have different stack-frames, saved registers, etc. void foo() { void bar() { goto L1; } /* more code */ L1: /* more code */ } Attached is a slight variant of nestfunct-5.c that crashes with the GCC i386 compiler on my Debian machine. $ gcc-4.0 ~/workspace/testgcc/nestfunct-5-variant.c -g $ ./a.out Aborted $ gcc-3.4 ~/workspace/testgcc/nestfunct-5-variant.c -g $ ./a.out Aborted -- Øyvind Harboe http://www.zylin.com
extern void abort (void); extern void exit (int); #ifndef NO_TRAMPOLINES void test(void (*t)(void)) { int i; for (i=0; i<10; i++) { t(); } } static void recursive (int n, void (*proc) (void)) { __label__ l1; int skip=0xdeadbeef; void do_goto (void) { goto l1; } test(do_goto); skip=0; if (n == 3) recursive (n - 1, do_goto); else if (n > 0) recursive (n - 1, proc); else (*proc) (); return; l1: if (skip!=0xdeadbeef) { if (n == 3) exit (0); else abort (); } } int main () { recursive (10, abort); abort (); } #else int main () { return 0; } #endif