Ah yes. Same with mine. 

Sent from my iPhone

> On Feb 27, 2015, at 16:53, Greg Parker <gpar...@apple.com> wrote:
> 
> 
>> On Feb 27, 2015, at 4:46 PM, Rick Mann <rm...@latencyzero.com> wrote:
>> 
>> 
>>> On Feb 27, 2015, at 16:45 , Greg Parker <gpar...@apple.com> wrote:
>>> 
>>> 
>>>> On Feb 27, 2015, at 4:28 PM, Rick Mann <rm...@latencyzero.com> wrote:
>>>> 
>>>> I'm updating some older Core Data code in which I made liberal use of 
>>>> transient properties to map NSNumber* types to scalar types like uint32_t. 
>>>> In practice, this doesn't gain much, especially with boxing syntax, and it 
>>>> makes the Core Data classes messier (shadow attributes, etc.).
>>>> 
>>>> The problem is, if I change an attribute's type to NSNumber*, and fail to 
>>>> modify every reference to that attribute, I often end up comparing 
>>>> pointers, not values:
>>>> 
>>>> @property (strong) NSNumber*        someAttribute;
>>>> 
>>>> if (obj.someAttribute > 42)
>>>> 
>>>> which needs to become:
>>>> 
>>>> if (obj.someAttribute.integerValue > 42)
>>>> 
>>>> I'd love an explicit warning for misuse of NSNumber*, but a 
>>>> pointer-integer comparison warning would be helpful. However, I don't see 
>>>> that among the available warnings in Xcode.
>>> 
>>> Here's how to answer "is there a warning for X".
>>> 1. Write a test file with the line of code that you want to be warned about.
>>> 2. Compile that file with -Weverything which enables literally every 
>>> warning supported by the compiler.
>>> 3. If the compiler warns about the code then the diagnostic message will 
>>> print the name of the warning flag, if any. Example:
>>>  test.m:13:1: warning: control reaches end of non-void function 
>>> [-Wreturn-type]
>>> If it doesn't print a warning name then that warning is on all the time, I 
>>> think.
>>> 
>>> When I run a test of your code, I get a warning unconditionally. It's 
>>> possible that my compiler is newer than yours; in your compiler there might 
>>> be no warning, or there might be a warning behind some warning flag. Try it 
>>> yourself.
>>> 
>>> test.m:12:13: warning: ordered comparison between pointer and integer
>>>    ('NSNumber *' and 'int')
>>>  if (t.x > 42) printf("bigger");
>>>      ~~~ ^ ~~
>> 
>> Great suggestion. Some versions of GCC will also tell you the command-line 
>> option that controls the warning it's emitting. I wish clang did that.
> 
> Er, that's exactly what Clang does, when there is a command-line option. 
> Example:
>  test.m:13:1: warning: control reaches end of non-void function 
> [-Wreturn-type]
> 
> Some of clang's warnings have no command-line option. Ordered comparison 
> between pointer and integer appears to be one of them, at least in my version 
> of the compiler.
> 
> 
> -- 
> Greg Parker     gpar...@apple.com     Runtime Wrangler
> 
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to