http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57428
Bug ID: 57428 Summary: Objective C exceptions completely broken in gcc 4.7 Product: gcc Version: 4.7.3 Status: UNCONFIRMED Severity: blocker Priority: P3 Component: objc Assignee: unassigned at gcc dot gnu.org Reporter: kostja.osipov at gmail dot com /* Compile with: gcc gcc-objective-c-exceptions.m -fobjc-exceptions -o test -lobjc */ #include <stdio.h> #include <stdlib.h> #import <objc/runtime.h> @interface Object { Class isa; } + (id) alloc; - (id) init; - (void) free; @end @implementation Object + (id) alloc { return class_createInstance(self, 0); } - (id) init { return self; } - (void) free { object_dispose(self); } @end @interface Frob: Object @end @implementation Frob: Object @end int proc() { @throw [[Frob alloc] init]; } int foo() { @try { return proc(); } @catch (Frob *) { printf("Catch(Frob *)\n"); return 0; } @catch (Object *) { printf("Catch(Object *)\n"); return 0; } @catch (id) { printf("Catch(id)\n"); return 0; } } int main(void) { foo(); return 0; } roman@work:~$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.7.2 (Debian 4.7.2-5) roman@work:~$ gcc gcc-objective-c-exceptions.m -fobjc-exceptions -o test -lobjc roman@work:~$ gdb ./test GNU gdb (GDB) 7.4.1-debian Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from test...(no debugging symbols found)...done. (gdb) r Starting program: test Program received signal SIGSEGV, Segmentation fault. __objc_responds_to (sel=<optimized out>, object=0x601340) at /home/packages/gcc/4.7/w/gcc-4.7-4.7.2/src/libobjc/sendmsg.c:398 398 res = sarray_get_safe (dtable, (size_t) sel->sel_id); (gdb) bt #0 __objc_responds_to (sel=<optimized out>, object=0x601340) at /home/packages/gcc/4.7/w/gcc-4.7-4.7.2/src/libobjc/sendmsg.c:398 #1 __objc_forward (object=0x601340, sel=0x6016a0, args=0x7fffffffe010) at /home/packages/gcc/4.7/w/gcc-4.7-4.7.2/src/libobjc/sendmsg.c:905 #2 0x00007ffff7bd24ed in __objc_word_forward (rcv=<optimized out>, op=<optimized out>) at /home/packages/gcc/4.7/w/gcc-4.7-4.7.2/src/libobjc/sendmsg.c:844 #3 0x0000000000400a7c in proc () #4 0x0000000000400ab0 in foo () #5 0x0000000000400b1b in main ()