This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libobjc/50002] New: class_replaceMethod does not work on class methods
- From: "nicola at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 6 Aug 2011 07:54:00 +0000
- Subject: [Bug libobjc/50002] New: class_replaceMethod does not work on class methods
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: nicola@gcc.gnu.org
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