CodeCheck Documentation
CodeCheck Documentation - MISRA C++ 2008

Standard: MISRA C++ 2008

The The Motor Industry Software Reliability Association (MISRA) guidelines for C++ published in 2008

MISRA Mission Statement: To provide assistance to the automotive industry in the application and creation within vehicle systems of safe and reliable software.

MISRA, The Motor Industry Software Reliability Association, is a collaboration between vehicle manufacturers, component suppliers and engineering consultancies which seeks to promote best practice in developing safety-related electronic systems in road vehicles and other embedded systems. To this end MISRA publishes documents that provide accessible information for engineers and management, and holds events to permit the exchange of experiences between practitioners.

www.misra-cpp.com

© MIRA Limited, 2008.

All RulesAdvisory RulesDocument RulesRequired Rules
Understand % Coverage98%100%50%99%
Understand Coverage181141166
Total Rules184142168
Check IDCheck NameSupportedAutomationCategory
MISRA08_0-1-10-1-1 A project shall not contain unreachable codeYesRequired
MISRA08_0-1-20-1-2 Infeasible PathsYesRequired
MISRA08_0-1-30-1-3 A project shall not contain unused variablesYesRequired
MISRA08_0-1-40-1-4 A project shall not contain non-volatile POD variables having only one use.YesRequired
MISRA08_0-1-50-1-5 A project shall not contain unused type declarationsYesRequired
MISRA08_0-1-70-1-7 The value returned by a function having a non-void return type that is not an overloaded operator shall always be usedYesRequired
MISRA08_0-1-80-1-8 All functions with void return type shall have external side effect(s)YesRequired
MISRA08_0-1-90-1-9 There shall be no dead codeNoRequired
MISRA08_0-1-100-1-10 All defined functions calledYesRequired
MISRA08_0-1-110-1-11 Unused Parameters in Non-virtual FunctionsYesRequired
MISRA08_0-1-120-1-12 There shall be no unused parameters (named or unnamed) in the set of parameters for a virtual function and all the functions that override itYesRequired
MISRA08_0-3-10-3-1 Minimization of run-time failures shall be ensured by the use of static analysis toolsYesDocument
MISRA08_0-3-20-3-2 If a function generates error information, then that error information shall be testedNoRequired
MISRA08_2-3-12-3-1 Trigraphs shall not be usedYesRequired
MISRA08_2-5-12-5-1 Digraphs shall not be usedYesAdvisory
MISRA08_2-7-12-7-1 The character sequence /* shall not be used within a C-style comment.YesRequired
MISRA08_2-7-22-7-2 Sections of code shall not be "commented out"YesRequired
MISRA08_2-10-12-10-1 Different identifiers shall be typographically unambiguousYesRequired
MISRA08_2-10-22-10-2 Shadowed IdentifiersYesRequired
MISRA08_2-10-32-10-3 A typedef name shall be a unique identifierYesRequired
MISRA08_2-10-42-10-4 A class, union or enum name (including qualification, if any) shall be a unique identifierYesRequired
MISRA08_2-10-52-10-5 The identifier name of a non-member object or function with static storage duration should not be reusedYesAdvisory
MISRA08_2-13-12-13-1 escape sequences are standardizedYesRequired
MISRA08_2-13-22-13-2 Octal constants (other than zero) and octal escape sequences (other than "\0" ) shall not be used.YesRequired
MISRA08_2-13-32-13-3 A "U" suffix shall be applied to all octal or hexadecimal integer literals of unsigned type.YesRequired
MISRA08_2-13-42-13-4 Literal suffixes shall be upper caseYesRequired
MISRA08_2-13-52-13-5 Narrow and wide string literals shall not be concatenatedYesRequired
MISRA08_3-1-13-1-1 It shall be possible to include any header file in multiple translation units without violating the One Definition RuleYesRequired
MISRA08_3-1-23-1-2 Functions shall not be declared at block scopeYesRequired
MISRA08_3-1-33-1-3 When an array is declared, its size shall either be stated explicitly or defined implicitly by initializationYesRequired
MISRA08_3-2-13-2-1 All declarations of an object or function shall have compatible typesYesRequired
MISRA08_3-2-23-2-2 The One Definition RuleYesRequired
MISRA08_3-2-33-2-3 A type, object or function that is used in multiple translation units shall be declared in one and only one fileYesRequired
MISRA08_3-2-43-2-4 An identifier with external linkage shall have exactly one definitionYesRequired
MISRA08_3-3-13-3-1 Objects or functions with external linkage shall be declared in a header fileYesRequired
MISRA08_3-3-23-3-2 If a function has internal linkage then all redeclarations shall include the static storage class specifierYesRequired
MISRA08_3-4-13-4-1 Declarations at Lowest ScopeYesRequired
MISRA08_3-9-13-9-1 The types used for an object, a function return type, or a function parameter shall be token-for-token identical in all declarations and re-declarationsYesRequired
MISRA08_3-9-23-9-2 Typedefs that indicate size and signedness should be used in place of the basic numerical typesYesAdvisory
MISRA08_3-9-33-9-3 The underlying bit representations of floating-point values shall not be usedYesRequired
MISRA08_4-5-14-5-1 Expressions with type bool shall not be used as operands to built-in operators other than the assignment operator =, the logical operators &&, ||, !, the equality operators == and !=, the unary & operator, and the conditional operatorYesRequired
MISRA08_4-5-24-5-2 Expressions with type enum shall not be used as operands to built-in operators other than the subscript operator [ ], the assignment operator =, the equality operators == and !=, the unary & operator, and the relational operators <, <=, >, >=YesRequired
MISRA08_4-5-34-5-3 Character OperatorsYesRequired
MISRA08_4-10-14-10-1 NULL shall not be used as an integer valueYesRequired
MISRA08_4-10-24-10-2 Literal zero (0) shall not be used as the null-pointer-constant.YesRequired
MISRA08_5-0-25-0-2 Limited dependence should be placed on C++ operator precedence rules in expressionsYesAdvisory
MISRA08_5-0-35-0-3 A cvalue expression shall not be implicitly converted to a different underlying typeYesRequired
MISRA08_5-0-45-0-4 An implicit integral conversion shall not change the signedness of the underlying typeYesRequired
MISRA08_5-0-55-0-5 There shall be no implicit floating-integral conversionsYesRequired
MISRA08_5-0-65-0-6 An implicit integral or floating-point conversion shall not reduce the size of the underlying typeYesRequired
MISRA08_5-0-75-0-7 There shall be no explicit floating-integral conversions of a cvalue expressionYesRequired
MISRA08_5-0-85-0-8 An explicit integral or floating-point conversion shall not increase the size of the underlying type of a cvalue expressionYesRequired
MISRA08_5-0-95-0-9 An explicit integral conversion shall not change the signedness of the underlying type of a cvalue expressionYesRequired
MISRA08_5-0-105-0-10 If the bitwise operators ~ and << are applied to an operand with an underlying type of unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operandYesRequired
MISRA08_5-0-115-0-11 The plain char type shall only be used for the storage and use of character valuesYesRequired
MISRA08_5-0-125-0-12 Signed char and unsigned char type shall only be used for the storage and use of numeric valuesYesRequired
MISRA08_5-0-145-0-14 The first operand of a conditional-operator shall have type boolYesRequired
MISRA08_5-0-175-0-17 Subtraction between pointers shall only be applied to pointers that address elements of the same arrayYesRequired
MISRA08_5-0-185-0-18 >, >=, <, <= shall not be applied to objects of pointer type, except where they point to the same arrayYesRequired
MISRA08_5-0-195-0-19 No more than 2 levels of pointer indirectionYesRequired
MISRA08_5-0-205-0-20 Non-constant operands to a binary bitwise operator shall have the same underlying typeYesRequired
MISRA08_5-0-215-0-21 Bitwise operators shall only be applied to operands of unsigned underlying typeYesRequired
MISRA08_5-2-35-2-3 Casts from a base class to a derived class should not be performed on polymorphic typesYesAdvisory
MISRA08_5-2-55-2-5 A cast shall not remove any const or volatile qualification from the type of a pointer or referenceYesRequired
MISRA08_5-2-65-2-6 A cast shall not convert a pointer to a function to any other pointer type, including a pointer to function typeYesRequired
MISRA08_5-2-85-2-8 An object with integer type or pointer to void type shall not be converted to an object with pointer type.YesRequired
MISRA08_5-2-95-2-9 Pointer to Integer CastYesAdvisory
MISRA08_5-2-105-2-10 The increment (++) and decrement (--) operators shall not be mixed with other operators in an expressionYesAdvisory
MISRA08_5-2-115-2-11 The comma operator, && operator and the || operator shall not be overloadedYesRequired
MISRA08_5-2-125-2-12 Array to Pointer DecayYesRequired
MISRA08_5-3-15-3-1 Each operand of the ! operator, the logical && or the logical || operators shall have type boolYesRequired
MISRA08_5-3-35-3-3 The unary & operator shall not be overloadedYesRequired
MISRA08_5-3-45-3-4 Evaluation of the operand to the sizeof operator shall not contain side effectsYesRequired
MISRA08_5-8-15-8-1 The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left hand operand.YesRequired
MISRA08_6-2-26-2-2 Floating-point expressions shall not be directly or indirectly tested for equality or inequalityYesRequired
MISRA08_6-2-36-2-3 Before preprocessing, a null statement shall only occur on a line by itself; it may be followed by a comment, provided that the first character following the null statement is a white-space characterYesRequired
MISRA08_6-3-16-3-1 The statement forming the body of a switch, while, do ... while or for statement shall be a compound statementYesRequired
MISRA08_6-4-16-4-1 An if ( condition ) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statementYesRequired
MISRA08_6-4-26-4-2 All if ... else if constructs shall be terminated with an else clauseYesRequired
MISRA08_6-4-46-4-4 A switch-label shall only be used when the most closely-enclosing compound statement is the body of a switch statementYesRequired
MISRA08_6-4-56-4-5 An unconditional throw or break statement shall terminate every non-empty switch-clauseYesRequired
MISRA08_6-4-66-4-6 The final clause of a switch statement shall be the default-clauseYesRequired
MISRA08_6-4-86-4-8 Every switch statement shall have at least one case clauseYesRequired
MISRA08_6-5-16-5-1 A for loop shall contain a single loop-counter which shall not have floating-point typeYesRequired
MISRA08_6-5-26-5-2 If loop-counter is not modified by -- or ++, then, within condition, the loop-counter shall only be used as an operand to <=, <, > or >=YesRequired
MISRA08_6-5-36-5-3 The loop-counter shall not be modified within condition or statementYesRequired
MISRA08_6-5-46-5-4 The loop-counter shall be modified by one of: --, ++, -= n, or += n; where n remains constant for the duration of the loopYesRequired
MISRA08_6-5-56-5-5 A loop-control-variable other than the loop-counter shall not be modified within condition or expressionYesRequired
MISRA08_6-5-66-5-6 A loop-control-variable other than the loop-counter which is modified in statement shall have type boolYesRequired
MISRA08_6-6-16-6-1 Any label referenced by a goto statement shall be declared in the same block, or in a block enclosing the goto statementYesRequired
MISRA08_6-6-26-6-2 The goto statement shall jump to a label declared later in the same function bodyYesRequired
MISRA08_6-6-46-6-4 For any iteration statement there shall be no more than one break or goto statement used for loop terminationYesRequired
MISRA08_6-6-56-6-5 A function shall have a single point of exit at the end of the functionYesRequired
MISRA08_7-1-17-1-1 A variable which is not modified shall be const qualifiedYesRequired
MISRA08_7-1-27-1-2 A pointer or reference parameter in a function shall be declared as pointer to const or reference to const if the corresponding object is not modifiedYesRequired
MISRA08_7-2-17-2-1 An expression with enum underlying type shall only have values corresponding to the enumerators of the enumerationYesRequired
MISRA08_7-3-17-3-1 Global Namespace DeclarationsYesRequired
MISRA08_7-3-27-3-2 The identifier main shall not be used for a function other than the global function mainYesRequired
MISRA08_7-3-37-3-3 There shall be no unnamed namespaces in header files.YesRequired
MISRA08_7-3-47-3-4 Using-directives shall not be used.YesRequired
MISRA08_7-3-57-3-5 Multiple declarations for an identifier in the same namespace shall not straddle a using-declaration for that identifierYesRequired
MISRA08_7-3-67-3-6 using-directives and using-declarations (excluding class scope or function scope using-declarations) shall not be used in header files.YesRequired
MISRA08_7-4-27-4-2 Assembler instructions shall only be introduced using the asm declaration.YesRequired
MISRA08_7-4-37-4-3 Assembly language shall be encapsulated and isolated.YesRequired
MISRA08_7-5-17-5-1 A function shall not return a reference or a pointer to an automatic variable (including parameters), defined within the function.YesRequired
MISRA08_7-5-27-5-2 The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist.YesRequired
MISRA08_7-5-47-5-4 Functions should not call themselves, either directly or indirectly.YesAdvisory
MISRA08_8-0-18-0-1 Single DeclarationsYesRequired
MISRA08_8-3-18-3-1 Parameters in an overriding virtual function shall either use the same default arguments as the function they override, or else shall not specify any default arguments.YesRequired
MISRA08_8-4-18-4-1 Functions shall not be defined using the ellipsis notationYesRequired
MISRA08_8-4-28-4-2 Use the same identifier in definition and declaration of functions.YesRequired
MISRA08_8-4-38-4-3 Always return a value in non-void functionsYesRequired
MISRA08_8-4-48-4-4 A function identifier shall either be used to call the function or it shall be preceded by &YesRequired
MISRA08_8-5-18-5-1 All variables shall have a defined value before they are usedYesRequired
MISRA08_8-5-28-5-2 Incorrect Initializer ListsYesAutomatedRequired
MISRA08_8-5-38-5-3 The = construct in enumerator list shall only be used on either the first item alone, or all items explicitly.YesRequired
MISRA08_9-3-19-3-1 Const member functions shall not return non-const pointers or references to class-dataYesRequired
MISRA08_9-3-29-3-2 Member functions shall not return non-const handles to class-dataYesRequired
MISRA08_9-3-39-3-3 If a member function can be made static then it shall be made static, otherwise if it can be made const then it shall be made constYesRequired
MISRA08_9-5-19-5-1 Unions shall not be usedYesRequired
MISRA08_9-6-19-6-1 When the absolute positioning of bits representing a bit-field is required, then the behavior and packing of bit-fields shall be documentedNoDocument
MISRA08_9-6-29-6-2 Bool, Unsigned, or Signed Bit-fieldsYesRequired
MISRA08_9-6-39-6-3 Enum Bit-fieldsYesRequired
MISRA08_9-6-49-6-4 (Fuzzy parser) Named bit-fields with signed integer type shall have a length of more than one bitYesRequired
MISRA08_10-1-110-1-1 Classes should not be derived from virtual basesYesAdvisory
MISRA08_10-1-210-1-2 A base class shall only be declared virtual if it is used in a diamond hierarchyYesRequired
MISRA08_10-1-310-1-3 An accessible base class shall not be both virtual and non-virtual in the same hierarchyYesRequired
MISRA08_10-3-110-3-1 There shall be no more than one definition of each virtual function on each path through the inheritance hierarchyYesRequired
MISRA08_10-3-210-3-2 Each overriding virtual function shall be declared with the virtual keyword.YesRequired
MISRA08_10-3-310-3-3 A virtual function shall only be overridden by a pure virtual function if it is itself declared as pure virtualYesRequired
MISRA08_11-0-111-0-1 Member data in non-POD class types shall be privateYesRequired
MISRA08_12-1-112-1-1 An object's dynamic type shall not be used from the body of its constructor or destructorYesRequired
MISRA08_12-1-212-1-2 Explicitly call all immediate and virtual base classesYesAdvisory
MISRA08_12-1-312-1-3 All constructors that are callable with a single argument of fundamental type shall be declared explicit.YesRequired
MISRA08_12-8-112-8-1 A copy constructor shall only initialize its base classes and the non-static members of the class of which it is a memberYesRequired
MISRA08_14-5-214-5-2 A copy constructor shall be declared when there is a template constructor with a single parameter that is a generic parameterYesRequired
MISRA08_14-5-314-5-3 A copy assignment operator shall be declared when there is a template assignment operator with a parameter that is a generic parameterYesRequired
MISRA08_14-7-114-7-1 All class templates, function templates, class template member functions and class template static members shall be instantiated at least onceYesRequired
MISRA08_14-8-114-8-1 Overloaded function templates shall not be explicitly specializedYesRequired
MISRA08_15-0-215-0-2 An exception object should not have pointer typeYesAdvisory
MISRA08_15-1-115-1-1 The assignment-expression of a throw statement shall not itself cause an exception to be thrownYesRequired
MISRA08_15-1-215-1-2 NULL shall not be thrown explicitlyYesRequired
MISRA08_15-1-315-1-3 An empty throw (throw;) shall only be used in the compound-statement of a catch handlerYesRequired
MISRA08_15-3-115-3-1 Exceptions shall be raised only after start-up and before termination of the programYesRequired
MISRA08_15-3-215-3-2 There should be at least one exception handler to catch all otherwise unhandled exceptionsYesAdvisory
MISRA08_15-3-315-3-3 Members in function-try-blocks in constructors or destructorsYesRequired
MISRA08_15-3-515-3-5 A class type exception shall always be caught by referenceYesRequired
MISRA08_15-3-615-3-6 Order of Catch Blocks with Derived ClassesYesRequired
MISRA08_15-3-715-3-7 Catch-All Statement Before LastYesRequired
MISRA08_15-4-115-4-1 Inconsistent Exception-SpecificationYesRequired
MISRA08_15-5-115-5-1 A class destructor shall not exit with an exceptionYesRequired
MISRA08_15-5-215-5-2 Exceptions thrown shall be the type indicated by the functionYesRequired
MISRA08_16-0-116-0-1 #include directives in a file shall only be preceded by other preprocessor directives or commentsYesRequired
MISRA08_16-0-216-0-2 Macros shall only be #define'd or #undef'd in the global namespaceYesRequired
MISRA08_16-0-316-0-3 #undef shall not be usedYesRequired
MISRA08_16-0-416-0-4 Function-like macros shall not be definedYesRequired
MISRA08_16-0-516-0-5 Arguments to a function-like macro shall not contain tokens that look like preprocessing directivesYesRequired
MISRA08_16-0-616-0-6 In the definition of a function-like macro, each instance of a parameter shall be enclosed in parentheses, unless it is used as the operand of # or ##YesRequired
MISRA08_16-0-716-0-7 Undefined macro identifiers shall not be used in #if or #elif preprocessor directives, except as operands to the defined operatorYesRequired
MISRA08_16-0-816-0-8 Invalid Preprocessor DirectivesYesRequired
MISRA08_16-1-116-1-1 The defined preprocessor operator shall only be used in one of the two standard formsYesRequired
MISRA08_16-1-216-1-2 All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are relatedYesRequired
MISRA08_16-2-116-2-1 The pre-processor shall only be used for file inclusion and include guardsYesRequired
MISRA08_16-2-216-2-2 C++ macros shall only be used for include guards, type qualifiers, or storage class specifiersYesRequired
MISRA08_16-2-316-2-3 Include guards shall be providedYesRequired
MISRA08_16-2-416-2-4 The ', ", /* or // characters shall not occur in a header file nameYesRequired
MISRA08_16-2-516-2-5 The backslash character should not occur in a header file nameYesAdvisory
MISRA08_16-2-616-2-6 The #include directive shall be followed by either a <filename> or "filename" sequenceYesRequired
MISRA08_16-3-116-3-1 There shall be at most one occurrence of the # or ## operators in a single macro definitionYesRequired
MISRA08_16-3-216-3-2 The # and ## operators should not be usedYesAdvisory
MISRA08_17-0-117-0-1 Reserved identifiers, macros and functions in the standard library shall not be defined, redefined or undefinedYesRequired
MISRA08_17-0-217-0-2 The names of standard library macros and objects shall not be reusedYesRequired
MISRA08_17-0-317-0-3 Standard Library Function NamesYesRequired
MISRA08_17-0-517-0-5 The setjmp macro and the longjmp function shall not be usedYesRequired
MISRA08_18-0-118-0-1 The C library shall not be usedYesRequired
MISRA08_18-0-218-0-2 The library functions atof, atoi and atol from library <cstdlib> shall not be usedYesRequired
MISRA08_18-0-318-0-3 The library functions abort, exit, getenv and system from library <cstdlib> shall not be usedYesRequired
MISRA08_18-0-418-0-4 The time handling functions of library <ctime> shall not be usedYesRequired
MISRA08_18-0-518-0-5 Unbounded Functions of <cstring>YesRequired
MISRA08_18-2-118-2-1 The macro offsetof shall not be used.YesRequired
MISRA08_18-4-118-4-1 Dynamic heap memory allocation shall not be used.YesRequired
MISRA08_18-7-118-7-1 The signal handling facilities of <csignal> shall not be usedYesRequired
MISRA08_19-3-119-3-1 The error indicator "errno" shall not be used.YesRequired
MISRA08_27-0-127-0-1 The stream input/output library <cstdio> shall not be usedYesRequired