This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libobjc/50003] New: -[Protocol respondsTo:] does not work with Clang
- 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:58:35 +0000
- Subject: [Bug libobjc/50003] New: -[Protocol respondsTo:] does not work with Clang
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: nicola@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.