Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367558 - Unnecessary "no break at the end of case" warning for "default" case
Summary: Unnecessary "no break at the end of case" warning for "default" case
Status: RESOLVED INVALID
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: CDT Codan Inbox CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-26 15:47 EST by Nathan Ridge CLA
Modified: 2012-02-23 11:30 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Ridge CLA 2011-12-26 15:47:18 EST
Example:

int main()
{
    int x;
    switch (x)
    {
        case 1: 
        {
            break;
        }
        case 2:
        {
            break;
        }
        default:
        {
            x = 0;
        }  // WARNING HERE: "No break at the end of case"
    }
}

I think warning about no break at the end of a "default" case that occurs as the last case in a switch statement (or even more generally, about no break at the end of *any* case that is the last case in a switch statement) is unnecessary and should be removed.
Comment 1 Simon Ducharme Boutin CLA 2011-12-31 02:20:05 EST
Hi Nathan,
You can disable this option by going in the project properties under C/C++ General / Code Analysis / No break at end of case / Customize Selected... / Check also the last "case" statement
Comment 2 Nathan Ridge CLA 2011-12-31 05:56:59 EST
Thanks Simon, I didn't know about these "Customize" settings. I've marked the issue as resolved.