This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libobjc/50002] New: class_replaceMethod does not work on class methods


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]