Details
-
Type:
Bug Detection
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Message:Remove this redundant specifier.
-
Highlighting:
-
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
- is implemented by
-
CPP-1562 Rule: Declaration specifiers should not be redundant
-
- Closed
-