http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50003

           Summary: -[Protocol respondsTo:] does not work with Clang
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libobjc
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: nic...@gcc.gnu.org


Jonathan Schleifer reports --

Hi!

When using -[Protocol respondsTo:] in the new GNU runtime, it seems to return
NO, even if the object conforms to the protocol. The code I use is this:

+ (BOOL)conformsToProtocol: (Protocol*)protocol                                 
{
       Class c;
       struct objc_protocol_list *pl;
       size_t i;

       for (c = self; c != Nil; c = class_get_super_class(c))                 
               for (pl = c->protocols; pl != NULL; pl = pl->next)             
                       for (i = 0; i < pl->count; i++)                         
                               if ([pl->list[i] conformsTo: protocol])         
                                       return YES;                             

       return NO;              
}

It works when just using gcc 4.6.1, and it seems to work with older versions of
the GNU runtime.

Thanks

PS: For clarity, Jonathan uses the GCC Objective-C runtime with other 
Objective-C compilers as well, such as clang.

Reply via email to