Summary: overly aggressive warning w.r.t. format specifier %z when using integer numeric literal
Originator: | kbeitz | ||
Number: | rdar://37326399 | Date Originated: | 2018.02.07 |
Status: | Open | Resolved: | |
Product: | Developer Tools | Product Version: | 9.3 beta 2 |
Classification: | Reproducible: | Always |
37326399 Summary: overly aggressive warning (or error in our case, since we enable warnings as errors) w.r.t. format specifier %z when using integer numeric literal TFNTableViewCell.m:447:81: Format specifies type 'ssize_t' (aka 'long') but the argument has type 'int' TFNFlushLogsAndReportNonFatalError(NSStringFromClass([self class]), 0, NSStringFromSelector(_cmd), [e description]); Crashlytics+TFNAdditions.h:43:254: Expanded from macro 'TFNFlushLogsAndReportNonFatalErrorConditionalSimulatorAbort' TFNLogWithoutCap(TLSLogLevelError, TFNLoggingChannel_Generic, @"Forcing app abort. (Not calling [[Crashlytics sharedInstance] reportError:] in the simulator.)\nerrorDomain = %@, errorCode = %zd, errorKey = %@, errorValue = %@\n%@", errorDomain, errorCode, errorKey, errorValue, [NSThread callStackSymbols]); \ in this case, %zd is used because we often pass an the code @property for an NSError, which will expand in that macro to be an NSInteger, which would then break a non-%z specifier since we still support both 32-bit NSInteger on 32-bit devices and 64-bit NSInteger on 64-bit devices. this will be the case for our product while supporting versions of iOS that support 32 bit devices (which would include iOS 10 that is supported on iPhone 5), it should not be the case that a warning is emitted for use of %z for a integer numeric literal. Steps to Reproduce: add code such as the following {code} #define MyLog(errorDomain, errorCode) NSLog(@"%@ - %zd", errorDomain, errorCode); NSError *error = [NSError errorWithDomain:@"domain" code:0 userInfo:nil]; MyLog(error.domain, error.code); // <-- compiles without error MyLog(error.domain, 0); // <-- compiler warning (or error with warnings as errors) {code} Expected Results: no warning Actual Results: Format specifies type 'ssize_t' (aka 'long') but the argument has type 'int' Version/Build: Xcode 9.3 beta 2 Configuration: macOS 10.13.3 (17D47) MacBook Pro (Retina, 15-inch, Mid 2015)
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!