[cfe-dev] Comparison of pointers between Objc subclasses

Eli Friedman eli.friedman at gmail.com
Tue Jul 1 19:50:15 PDT 2008


On Tue, Jul 1, 2008 at 4:06 PM, Jean-Daniel Dupas
<devlists at shadowlab.org> wrote:
> At least for GCC:
>
>  id generic;
>  NSObject *base = nil;
>  NSArray *array = nil;
>  NSMutableArray *subArray = nil;
>
>  base = array; // OK
>  array = base; // Warning: assignment from distinct Obj-C Type
>
>  array = subArray; // OK
>  subArray = array; // Warning:  assignment from distinct Obj-C Type
>
>  generic = array; // OK
>  array = generic; // OK
>

Okay... would you mind checking few more potentially interesting cases?
Redeclaration (i.e. nsarray*a;nsmutablearray*a;)
Relational operators (<= and friends)
Subtraction (i.e. nsarray-nsmutablearray)
Assigning pointer to pointer (i.e. nsmutablearray**=nsarray**, and vice versa)

I'd do it myself, but I don't know enough objc to write a testcase myself.

-Eli



More information about the cfe-dev mailing list