http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50002
Summary: class_replaceMethod does not work on class methods
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libobjc
AssignedTo: [email protected]
ReportedBy: [email protected]
Reported by Jonathan Schleifer --
#include <stdio.h>
#include <assert.h>
#import <objc/Object.h>
#import <objc/runtime.h>
id
alloc(Class self, SEL _cmd)
{
puts("Foo!");
return nil;
}
int
main()
{
Method method = class_getClassMethod([Object class], @selector(alloc));
assert(method != NULL);
/* INCOMPATIBLE to Apple! class_pointer should be isa!! */
class_replaceMethod([Object class]->class_pointer, @selector(alloc),
(IMP)alloc, method_getTypeEncoding(method));
[Object alloc];
return 0;
}
> If you change Object to NSObject and class_pointer to isa, it works on OS X.
Thanks