public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libobjc/50002] New: class_replaceMethod does not work on class methods
@ 2011-08-06  7:54 nicola at gcc dot gnu.org
  2011-08-06 14:20 ` [Bug libobjc/50002] " nicola at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-08-06  7:54 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-14 17:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-06  7:54 [Bug libobjc/50002] New: class_replaceMethod does not work on class methods nicola at gcc dot gnu.org
2011-08-06 14:20 ` [Bug libobjc/50002] " nicola at gcc dot gnu.org
2011-08-06 14:22 ` nicola at gcc dot gnu.org
2011-10-14 17:10 ` nicola at gcc dot gnu.org
2011-10-14 17:12 ` nicola at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).