• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: error in using NSNumber's numberWithInt: method not flagged
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: error in using NSNumber's numberWithInt: method not flagged


  • Subject: Re: error in using NSNumber's numberWithInt: method not flagged
  • From: Kyle Sluder <email@hidden>
  • Date: Sun, 09 Jun 2013 13:32:50 -0700

On Jun 9, 2013, at 1:26 PM, Boyd Collier <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: error in using NSNumber's numberWithInt: method not flagged
      • From: John McCall <email@hidden>
References: 
 >error in using NSNumber's numberWithInt: method not flagged (From: Boyd Collier <email@hidden>)

  • Prev by Date: error in using NSNumber's numberWithInt: method not flagged
  • Next by Date: Re: error in using NSNumber's numberWithInt: method not flagged
  • Previous by thread: error in using NSNumber's numberWithInt: method not flagged
  • Next by thread: Re: error in using NSNumber's numberWithInt: method not flagged
  • Index(es):
    • Date
    • Thread