Compiler mistakenly suggests that function with "default:" in switch reaches end without returning a value
| Originator: | news | ||
| Number: | rdar://13253301 | Date Originated: | |
| Status: | Resolved: | ||
| Product: | Developer Tools | Product Version: | Xcode 4.6 (4H127) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
Compiler suggests that "Control may reach end of non-void function" when function contains switch and default case with return statement
Steps to Reproduce:
Launch Xcode
Create a new project
Add following code
- (NSString *)a:(NSUInteger)b
{
switch (b) {
case 0:
return @"zero";
case 1:
return @"one";
default:
return @"something else";
}
}
Expected Results:
Code compile without warnings
Actual Results:
Project compiles with "Control may reach end of non-void function" warning
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!