On Jun 9, 2013, at 1:26 PM, Boyd Collier <bcolli...@cox.net> wrote:

> 
> Quite by chance, I stumbled on to what seems to be an error that ought to be 
> caught by the compiler but wasn't.  Here's an example:
> 
>    NSNumber *testNumber = [NSNumber numberWithInt:5];
>    int testInt = (int)testNumber;
> 
> […snip…]
> 
> Should I file a bug report or is this a well-known anomaly that I've just 
> come across?

Sitting on a runway right now, so I can't double-check the C spec, but I 
believe this is a consequence of C's use of integers for truth types.

A pointer must be convertible to integer type, because it can be used in the 
form `if (expressionOfPointerType)`. It follows that casting to int must also 
be allowed. I'm not sure what the spec says about the actual value of the 
result.

--Kyle Sluder
_______________________________________________

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