Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367558

Summary: Unnecessary "no break at the end of case" warning for "default" case
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-codanAssignee: CDT Codan Inbox <cdt-codan-inbox>
Status: RESOLVED INVALID QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: cdtdoug, malaperle, sducharme
Version: 8.1.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

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.