This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libobjc/53944] New: Can't catch C++ exception in Objective C
- From: "kostja.osipov at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 12 Jul 2012 17:37:29 +0000
- Subject: [Bug libobjc/53944] New: Can't catch C++ exception in Objective C
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53944
Bug #: 53944
Summary: Can't catch C++ exception in Objective C
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libobjc
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: kostja.osipov@gmail.com
There is no way with GCC runtime to catch a C++ exception in Objective C code.
The catch-all clause doesn't work.
At some point this limitation was documented, but later removed from the
manual.
Right now the code compiles, but fails to produce expected results.
kostja@atlas:~$ cat bar.cc
extern "C" int bar()
{
throw "exception";
}
kostja@atlas:~$ cat foo.m
#include <stdio.h>
extern int bar();
int main()
{
@try {
bar();
} @catch (...) {
printf("caught\n");
} @finally {
printf("finally\n");
}
}
kostja@atlas:~$ g++ -c -fexceptions bar.cc
kostja@atlas:~$ g++ -c -fexceptions -fobjc-exceptions foo.m
kostja@atlas:~$ g++ foo.o bar.o -lobjc
kostja@atlas:~$ ./a.out
terminate called after throwing an instance of 'char const*'
[1] 20822 abort (core dumped) ./a.out