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

2013-06-10 Thread Sean McBride
On Sun, 9 Jun 2013 13:45:52 -0700, John McCall said: >Playing with the bit-representation of Objective-C pointers specifically >is ill-advised because the implementation reserves the right to play its >own games with object pointers (such as the optimized representation of >integer values when box

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

2013-06-09 Thread Jens Alfke
This is correct behavior. C allows casting between pointer and integer types. It’s used a lot for doing pointer arithmetic. (C’s ancestor BCPL didn’t even have separate integer and pointer types.) You might get an optional compiler warning if the integer type narrower than a pointer, but that’s

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

2013-06-09 Thread John McCall
On Jun 9, 2013, at 1:32 PM, Kyle Sluder wrote: > On Jun 9, 2013, at 1:26 PM, Boyd Collier 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]; >

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

2013-06-09 Thread Kyle Sluder
On Jun 9, 2013, at 1:26 PM, Boyd Collier 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…]

error in using NSNumber's numberWithInt: method not flagged

2013-06-09 Thread Boyd Collier
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; However, the value of testInt when running the above is wildly in