[cfe-dev] Comparison of pointers between Objc subclasses

David Chisnall csdavec at swansea.ac.uk
Wed Jul 2 03:58:48 PDT 2008


On 2 Jul 2008, at 00:22, Ted Kremenek wrote:

> Are pointer type compatibility checks for assignments and conversions
> being handled in the same way?  I can understand why assigning a base
> type to a derived type is dangerous, but it seems to me that
> comparisons like these should be legal.  I'm only raising this point
> because the code snippet with the warning involved a comparison, not
> an assignment.

Comparisons between ObjC pointers should contain an implicit cast to  
id.  I tweaked CodeGen to do this  and sent the patch a month or so  
ago, but it wasn't an ideal solution since the problem is really in  
Sema, and it only fixed a few cases where Sema was doing almost the  
right thing but omitting the implicit cast.

Currently there are lots of Objective-C type-system related bugs in  
clang.  I hope to have some time in the next few weeks to be able to  
take a look at it.  The Objective-C type system doesn't map very  
cleanly to the LLVM type system, unfortunately, and there are lots of  
places where implicit casts need to be emitted but aren't.

David



More information about the cfe-dev mailing list