OS X 10.10.4, Xcode 7 beta 3 This code produces some (for me) unexpected results:
NSUInteger unsignedSize = 3; NSInteger signedSize = 3; for ( NSInteger rawValue = -6; rawValue < 5; rawValue++ ) { NSInteger modValueU = rawValue; NSInteger modValueS = rawValue; modValueU %= unsignedSize; modValueS %= signedSize; fprintf(stderr,"rawValue %+2ld modValueU %+2ld modValueS %+2ld\n", rawValue, modValueU, modValueS); }; rawValue -6 modValueU +1 modValueS +0 expected modValueU = 0 rawValue -5 modValueU +2 modValueS -2 expected modValueU = 1 rawValue -4 modValueU +0 modValueS -1 expected modValueU = 2 rawValue -3 modValueU +1 modValueS +0 expected modValueU = 0 rawValue -2 modValueU +2 modValueS -2 expected modValueU = 1 rawValue -1 modValueU +0 modValueS -1 expected modValueU = 2 rawValue +0 modValueU +0 modValueS +0 rawValue +1 modValueU +1 modValueS +1 rawValue +2 modValueU +2 modValueS +2 rawValue +3 modValueU +0 modValueS +0 rawValue +4 modValueU +1 modValueS +1 Probably the answer is: works as documented (but I can’t figure out the rule it is following). But even if so: why are there no warnings, compiling with these flags: CLANG_WARN_IMPLICIT_SIGN_CONVERSION GCC_WARN_ABOUT_POINTER_SIGNEDNESS GCC_WARN_SIGN_COMPARE Gerriet. _______________________________________________ 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