Clang not generating warnings for unused return value of [NSArray sortedArrayUsingComparator]

Originator:nick.pannuto
Number:rdar://20864380 Date Originated:5/7/2015
Status:Open Resolved:Closed
Product:iOS SDK Product Version:OS X 10.10.3, Xcode Version 6.3.1 (6D1002), Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Classification:Serious Bug Reproducible:Always
 
Summary:
With -Wunused-result, -Wreturn-type, and -Wunused-value passed into Other Warning Flags, I was not getting any warning for the following code: [@[@"bacon", @"bakon", @"∆"] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { return NSOrderedDescending; }];

Steps to Reproduce:
1. Create a new Xcode project
2. Add -Wunused-result, -Wreturn-type, and -Wunused-value to your Other Warning Flags
3. Throw '[@[@"bacon", @"bakon", @"∆"] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { return NSOrderedDescending; }];' somewhere in your code
4. Build

Expected Results:
There should be a warning 

Actual Results:
There was no warning

Version:
OS X 10.10.3, Xcode Version 6.3.1 (6D1002), Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)

Notes:
Wouldn't have caught this if I didn't realize that I was sorting a non mutable array, I originally thought my sort was broken, took some time for me to realize that I wasn't saving the result of the sort. 

Configuration:
rMBP (Mid 2012)

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!