Last active
December 17, 2015 16:59
-
-
Save rtsisyk/5642385 to your computer and use it in GitHub Desktop.
GCC 4.7 libobjc2 bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* compile with | |
* gcc -std=gnu99 -pthread -fobjc-exceptions -O0 bug.m -o bug \ | |
* ../third_party/libobjc/libobjc.a | |
* Target: x86_64-linux-gnu | |
* gcc version 4.7.2 (Debian 4.7.2-5) | |
*/ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <objc/runtime.h> | |
@interface tnt_Object { | |
Class isa; | |
} | |
+ (id) alloc; | |
- (id) init; | |
- (void) free; | |
@end | |
@implementation tnt_Object | |
+ (id) alloc | |
{ | |
return class_createInstance(self, 0); | |
} | |
- (id) init | |
{ | |
return self; | |
} | |
- (void) free | |
{ | |
object_dispose(self); | |
} | |
@end | |
static int | |
dothrow(void) | |
{ | |
@try { | |
/* the next line is important for the test */ | |
char buf[] = { 0x0, 0x0, 0x0, 0x0, 0x0}; | |
(void) buf; | |
@throw [[tnt_Object alloc] init]; | |
} @catch (tnt_Object *e) { | |
fprintf(stderr, "catch 1\n"); | |
return -1; | |
} @catch (id e) { | |
return -1; | |
} | |
return 0; | |
} | |
int | |
main(void) | |
{ | |
@try { | |
dothrow(); | |
} @catch (tnt_Object *e) { | |
fprintf(stderr, "catch 2\n"); | |
} | |
fprintf(stderr, "exit\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment