http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53944

--- Comment #2 from Konstantin Osipov <kostja.osipov at gmail dot com> ---
Objective C++ exception handling is broken in gcc completely, here's a small
example of trying to use C++ and Objective C exceptions together which
SEGFAULTs:



kostja@olah ~ % cat foo.mm 
#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;
    }
    @catch (...) {
        printf("Catch(...)\n");
        return 0;
    }
}

int main(void)
{
    foo();
    return 0;
}
kostja@olah ~ % g++ -fobjc-exceptions foo.mm -lobjc
kostja@olah ~ % ./a.out 
zsh: segmentation fault (core dumped)  ./a.out

Reply via email to