Clang ignores missing return statements in methods containing @try/@catch constructs

Originator:mnem
Number:rdar://29050563 Date Originated:11/3/2016
Status:Open Resolved:
Product: Product Version:
Classification: Reproducible:
 
Summary:
If a returning method has a @try/@catch construct, Xcode/clang does not treat a missing return statement as an error.

The attached project contains sample code illustrating the problem. Inside ViewController.m there is a method called tryCatchWhoops which does not have a return statement after the @catch, causing an undefined value to be returned to the call in viewDidLoad.

Steps to Reproduce:
1. Create a method which returns a value, e.g. - (NSArray *)foo {}
2. Xcode/clang will mark the function with an error indicating that control reaches the end of a non void function.
3. Add a minimal @try/@catch construct to the function, e.g. @try {} @catch (NSException *e) {}

Expected Results:
I expect Xcode/clang to still have an error indicating that control reaches the end of a non void function.

Actual Results:
Xcode/clang no longer indicates that control reaches the end of a non void function, allowing the erroneous function to be called.

Version:
Xcode Version 8.1 (8B62)
macOS 10.12.1 (16B2555)

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!