Xcode 9.3 beta 1: overly aggressive warning regarding %z formatting for NSInteger

Originator:kbeitz
Number:rdar://36913956 Date Originated:2017.01.26
Status:Closed as Dupe (36874921) By Apple Resolved:Duplicate 36874921 still open at time this was closed by me
Product:Developer Tools Product Version:9.3 beta 1
Classification: Reproducible:Always
 
Summary: 

NSLog(@"max NSInteger = %zi", integer); // <-- compiler warning/error
Values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead; replace '%zi", ' with '"%li, (long)'

%zi is the format specifier for ssize_t which is a singed integer value that is 32-bits on 32-bit OSes and 64-bits on 64-bit OSes (just like NSInteger)... we should not have to change this, but the compiler is now more sensitive

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 .



Steps to Reproduce: add code such as the following

NSInteger integer = 123456789;
NSLog(@"max NSInteger = %zi", integer); // <-- compiler warning/error

Expected Results: no warning

Actual Results: a warning "Values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead; replace '%zi", ' with '"%li, (long)'"

Version/Build: Xcode 9.3 beta


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!