Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3689

Declaration specifiers should not be redundant

    XMLWordPrintable

    Details

    • Type: Bug Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Remove this redundant specifier.
    • Highlighting:
      Hide

      the second redundant specifier

      Show
      the second redundant specifier
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way, MISRA C++ 2008 recommended
    • Covered Languages:
      C, C++, Objective-C
    • Irrelevant for Languages:
      ABAP, C#, Cobol, CSS, Flex, HTML, Java, JavaScript, PHP, PL/I, PL/SQL, Python, RPG, Swift, VB.Net, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Scope:
      Main Sources, Test Sources

      Description

      Redundant declaration specifiers should be removed or corrected. Typically, they represent bugs. A specifier modifies the type or pointer to its left. Only when it is at the far left does it apply to the right.

      Noncompliant Code Example

      const int const * v1a; // Noncompliant; both const specifiers apply to int
      const int const * v1b; // Noncompliant
      static static int v2;  // Noncompliant
      

      Compliant Solution

      const int *       v1a;  // pointer to a const int. same meaning as before but less confusing
      int const * const v1b;  // const pointer to a const int
      static int         v2;
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              alban.auzeill Alban Auzeill
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: