Main Content

Polyspace Support for Coding Standards

Polyspace® Bug Finder and Polyspace as You Code support various coding standards. Check the compliance of your code with these standards by analyzing your individual translation units in the IDE, and then analyzing your entire source code during integration. Polyspace as You Code supports a subset of rules that Bug Finder supports. See Checkers Deactivated in Polyspace as You Code Analysis (Polyspace Access).

Summary of Polyspace Support

StandardReleaseStatically Enforceable RulesRequired or Mandatory Rules
MISRA C++:2023October 2023156 out of 156 decidable rules in the standard

  • 5 out of 5 mandatory rules

  • 124 out of 124 required rule

AUTOSAR C++1410-31-2018349 out of 349 rules in the standard337 out of 362 rules in the standard
MISRA C++:2008June 2008 a 195 out of 198 rules in the standard
MISRA C:2012

  • March 2013

  • April 2016 (Amendment 1)

  • June 2017 (TC1)

  • January 2018 (Amendment 2)

  • March 2022 (TC2)

  • October 2022 (Amendment 3)

141 out of 149 rules in the standard146 out of 160 rules in the standard
MISRA C:2023April 2023141 out of 149 rules in the standard146 out of 160 rules in the standard
CERT C2016120 out of 120 rules in the standard120 out of 120 rules in the standard

a MISRA C++:2008 standard does not categorize rules based on their static enforceability

Coding standards categorize the rules based on their obligation level or their static enforceability. Polyspace supports rules that are considered nonenforceable or partially enforceable by the standards. Enforcing these rules require a manual review process, which can be assisted by the Polyspace results.

AUTOSAR C++14

The AUTOSAR C++14 standard categorizes the rules based on their obligation level and enforcement by static analysis.

Obligation Level

CategoryRules Implemented in Bug FinderRules in the Standard
Required: The code must follow these rules.337362
Advisory: The code is advised to follow these rules to a reasonable practical extent.3335
 Total: 370 

Enforcement by Static Analysis Tool

CategoryRules Implemented in Bug FinderRules in the Standard
Automated: Static analysis tools can detect all violation of these rules.327327a
Partially automated: Static analysis tools cannot detect all possible violations of these rules. You need manual code review or other tools to completely enforce these rules. Polyspace shows the subset of all possible issues. For details about which issues Polyspace detects for a particular rule, see the Polyspace Implementation section in the reference page of the rule.2222
Nonautomated: Static analysis tools cannot detect all possible violations of these rules. You need manual code review or other tools to completely enforce these rules. Polyspace shows the subset of all possible issues. For details about which issues Polyspace detects for a particular rule, see the Polyspace Implementation section in the reference page of the rule.2146

a The AUTOSAR C++14 standard contains 329 Automated rules. The rules A0-4-3 and A1-4-3 are not enforceable by a static analysis tool. These rules might be enforced by a compiler.

The Automated and Partially automated rules are statically enforceable. In total, Polyspace supports 349 statically enforceable rules and 337 required rules. See:

MISRA C++:2008

The MISRA C++:2008 standard categorizes the rules based on their obligation level.

CategoryRules Implemented in Bug FinderRules in the Standard
Required: The code must follow these rules.195198
Advisory: The code is advised to follow these rules to a reasonable practical extent.1818
Document: These rules are associated with different features including #pragmas, floating-point arithmetic, or bit fields. Whenever these features are used, the code must follow the associated rule.112
 Total: 214 

See Required or Mandatory MISRA Coding Rules Supported by Polyspace Bug Finder.

MISRA C:2012

The MISRA C:2012 standard classifies the guidelines as either a rule or a directive. Polyspace supports the original MISRA C:2012 standard, technical corrigenda 1 and 2, and amendments 1, 2, 3, and 4. See Polyspace Support for MISRA C: 2012 Technical Corrigenda and Amendments.

MISRA C:2012 Rules

A rule is a guideline that can be described completely. Compliance with a rule can be checked statically with some limitation. The rules are further categorized based on different properties.

Obligation Level

CategoryRules Implemented in Bug FinderRules in the Standard
Mandatory: These are guidelines that compliant C code must follow. The standard does not permit deviations from these guidelines.1823
Required: These are guidelines that compliant C code must follow. The standard permits only the deviations that you formally record and authorize.128137
Advisory: These are recommended guidelines. The standard permits deviation from these guidelines without any formal record. It is a best practice to follow these guidelines to a reasonably practical degree and record the deviations.3940
 Total: 185 

Compliant C code must follow the Mandatory and Required rules. Polyspace supports all such rules.

Static Enforceability

CategoryRules Implemented in Bug FinderRules in the Standard
Decidable: A rule is decidable if a static analysis tool can check compliance with the rule in every possible case.141149
Undecidable: A rule is undecidable if a static analysis tool can check compliance to it only in certain cases. Polyspace shows the subset of all possible issues. For details about which issues Polyspace detects for a particular rule, see the Polyspace Implementation section in the reference page of the rule.4451

Analysis Scope

CategoryRules Implemented in Bug FinderRules in the Standard
Single Translation Unit: You can find all violations of these rules by checking each translation unit of a project individually.128135
System: You can find all violations of these rules only by analyzing the entire project or system.5765

For details about Polyspace support of decidable MISRA C:2012 rules, see Decidable MISRA Coding Rules Supported by Polyspace Bug Finder.

MISRA C:2012 Directives

Directives are guidelines that cannot be completely described. Checking compliance with these directives requires more information in addition to the code. Static analysis might assist in checking compliance with directives. The directives are categorized based on obligation level.

Obligation Level

CategoryDirectives Implemented in Bug FinderDirectives in the Standard
Required: These are guidelines that compliant C code must follow. The standard permits only the deviations that you formally record and authorize.1214
Advisory: These are recommended guidelines. The standard permits deviation from these guidelines without any formal record. It is a best practice to follow these guidelines to a reasonably practical degree and record the deviations.67

Static Enforceability

CategoryDirective Implemented in Bug FinderDirective in the Standard
Decidable: A directive is decidable if a static analysis tool can check compliance with the directive in every possible case.00
Undecidable: A directive is undecidable if a static analysis tool can check compliance to it only in certain cases. Polyspace shows the subset of all possible issues. For details about which issues Polyspace detects for a particular directive, see the Polyspace Implementation section in the reference page of the directive.1821

See Undecidable MISRA C:2012 Rules and Directives Supported by Polyspace Bug Finder.

MISRA C:2023

The MISRA C:2023 standard classifies the guidelines as either a rule or a directive.

MISRA C:2023 Rules

A rule is a guideline that can be described completely. Compliance with a rule can be checked statically with some limitation. The rules are further categorized based on different properties.

Obligation Level

CategoryRules Implemented in Bug FinderRules in the Standard
Mandatory: These are guidelines that compliant C code must follow. The standard does not permit deviations from these guidelines.1823
Required: These are guidelines that compliant C code must follow. The standard permits only the deviations that you formally record and authorize.128137
Advisory: These are recommended guidelines. The standard permits deviation from these guidelines without any formal record. It is a best practice to follow these guidelines to a reasonably practical degree and record the deviations.3940
 Total: 185 

Static Enforceability

CategoryRules Implemented in Bug FinderRules in the Standard
Decidable: A rule is decidable if a static analysis tool can check compliance with the rule in every possible case.141149
Undecidable: A rule is undecidable if a static analysis tool can check compliance to it only in certain cases. Polyspace shows the subset of all possible issues. For details about which issues Polyspace detects for a particular rule, see the Polyspace Implementation section in the reference page of the rule.4451

Analysis Scope

CategoryRules Implemented in Bug FinderRules in the Standard
Single Translation Unit: You can find all violations of these rules by checking each translation unit of a project individually.128135
System: You can find all violations of these rules only by analyzing the entire project or system.5765

MISRA C:2023 Directives

Directives are guidelines that cannot be completely described. Checking compliance with these directives requires more information in addition to the code. Static analysis might assist in checking compliance with directives. The directives are categorized based on obligation level.

Obligation Level

CategoryDirectives Implemented in Bug FinderDirectives in the Standard
Required: These are guidelines that compliant C code must follow. The standard permits only the deviations that you formally record and authorize.1214
Advisory: These are recommended guidelines. The standard permits deviation from these guidelines without any formal record. It is a best practice to follow these guidelines to a reasonably practical degree and record the deviations.67

Static Enforceability

CategoryDirective Implemented in Bug FinderDirective in the Standard
Decidable: A directive is decidable if a static analysis tool can check compliance with the directive in every possible case.00
Undecidable: A directive is undecidable if a static analysis tool can check compliance to it only in certain cases. Polyspace shows the subset of all possible issues. For details about which issues Polyspace detects for a particular directive, see the Polyspace Implementation section in the reference page of the directive.1821

CERT C

Polyspace supports all statically enforceable rules in the CERT C standard. The standard categorizes the guidelines into rules and recommendations. Polyspace does not support rules that are being removed or under construction.

CategoryChecks Implemented in Bug FinderChecks in the Standard
Rule: These guidelines are required. Violation of these guidelines might compromise the safety, security, or reliability of a system. Static analysis tools can enforce compliance with these guidelines.120120
Recommendation: These guidelines are meant to improve the readability, safety, and security of a system. Static analysis can only detect a subset of violations of these guidelines. Polyspace shows the subset of all possible issues. For details about which issues Polyspace detects, see the reference page of these rules.94183

Other

Polyspace also supports these coding rule standards.

StandardRules Implemented in Bug Finder
MISRA C:2004132 out of 142 rules in the standard
MISRA AC AGC130 out of 142 in the standard
ISO/IEC TS 1796146 out of 46 in the standard
JSF AV C++160 out of 234 in the standard
CERT C++163 out of 163 in the standard
CWE

192 (version 4.12), including:

  • 76 out of 82 C specific rules (CWE-658).

  • 81 out of 86 C++ specific rules (CWE-659).

See Also

| | | | | |

Related Topics