On Feb 24, 2012, at 12:47 PM, Kyle Sluder wrote: > But I'm not sure the integer conversion is necessarily relevant. The > semantics of the if statement are defined by §6.8.4.1 ¶2: "the first > substatement is executed if the expression compares unequal to 0." It > is left unspecified if '0' is an integer constant expression or an > arithmetic expression with an integer value of zero. If the former, > then the pointer is compared against the null pointer constant per > §6.3.2.3 ¶4. If the latter, the pointer is converted to integer per > implementation-defined behavior and the comparison is performed, which > might itself result in undefined behavior per §6.5 ¶5 since the > conversion is not guaranteed to produce a value within range of any > integer type.
Thing is: if(foo) is equivalent to if(foo != 0), which I think results in 0 being treated as a pointer, not the pointer being cast to int, anyway if if(foo) could fail, so could if(foo != 0)... Also I think "Except as previously specified..." covers the case that NULL pointers convert to int 0... -- Scott Ribe scott_ribe@elevated-dev.comhttp://www.elevated-dev.com/ (303) 722-0567 voice _______________________________________________ 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