Uploaded image for project: 'SonarCFamily'
  1. SonarCFamily
  2. CPP-1882

NonEmptyCaseWithoutBreak: Fix false-positives

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.0
    • Component/s: None
    • Labels:
      None

      Description

      int plus1(int a) {
        switch (a) {
          case 1: // false-positive
            if (unknown()) {
              return 2;
            } else {
              return 2;
            }
          default:
            return a + 1;
        }
      }
      
      [[noreturn]] void noreturn0();
      __attribute__((noreturn)) void noreturn1();
      __attribute__((noreturn)) void exit(int status);
      
      int fun(int val) {
        switch ( val ) {
           case 1:  noreturn0(); // fp
           case 2:  noreturn1(); // fp
           case 3:  exit( 3 ); // fp
           default: return 0;
        }
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              massimo.paladin Massimo PALADIN
              Reporter:
              massimo.paladin Massimo PALADIN
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: