MISRA C++:2008 rules
| Guideline | Category | Checker name and description |
|---|---|---|
| Dir. 0.3.1 | Document | |
| Dir. 0.4.1 | Document | |
| Dir. 0.4.2 | Document | |
| Dir. 0.4.3 | Document | |
| Dir. 1.0.2 | Document | |
| Dir. 1.0.3 | Document | |
| Dir. 2.2.1 | Document | |
| Dir. 7.4.1 | Document | |
| Dir. 9.6.1 | Document | |
| Dir. 15.0.1 | Document | |
| Dir. 16.6.1 | Document | |
| Dir. 17.0.4 | Document | |
| Rule 0 | Required |
UNREACH.ENUM Code is unreachable due to the possible value(s) of an enum UNREACH.GEN Unreachable code UNREACH.RETURN Unreachable Void Return UNUSED.FUNC.GEN Function defined but not used MISRA.FUNC.UNUSEDPAR Formal parameter of a non-virtual function is not used MISRA.FUNC.UNUSEDPAR.UNNAMED Unnamed formal parameter of a non-virtual function is not used MISRA.FUNC.VIRTUAL.UNUSEDPAR Formal parameter of a virtual function set is not used CWARN.NOEFFECT.UCMP.GE Comparison of unsigned value against 0 is always true CWARN.NOEFFECT.UCMP.GE.MACRO Comparison of unsigned value against 0 within a macro is always true CWARN.NOEFFECT.UCMP.LT Comparison of unsigned value against 0 is always false CWARN.NOEFFECT.UCMP.LT.MACRO Comparison of unsigned value against 0 within a macro is always false LV_UNUSED.GEN Local variable unused MISRA.FUNC.UNUSEDRET Return value of a non-void function is not used VA_UNUSED.GEN Value is Never Used after Assignment VA_UNUSED.INIT Value is Never Used after Initialization MISRA.ASSIGN.OVERLAP Object is assigned to an overlapping object |
| Rule 1 | Required | |
| Rule 2 | Required |
MISRA.VAR.HIDDEN Identifier declared in an inner scope hides identifier in outer scope MISRA.TYPEDEF.NOT_UNIQUE Typedef name is used for another entity MISRA.CT.UNIQUE.ID Identifier clashes with tag name MISRA.VAR.UNIQUE.STATIC Identifier with static storage specifier clashes with other identifier MISRA.TYPE.NAMECLASH.CPP.2008 Identifier in one name space has same spelling as identifier in other name space MISRA.TOKEN.WRONGESC.CPP.2008 Incorrect escape sequence in a literal MISRA.TOKEN.OCTAL.ESCAPE Usage of octal escape sequences MISRA.TOKEN.OCTAL.INT Usage of octal integer constants MISRA.LITERAL.UNSIGNED.SUFFIX Unsigned integer literal without 'U' suffix MISRA.LITERAL.SUFFIX.CASE Literal suffix in lower case. MISRA.STRINGS.CONCAT Narrow and wide string literals concatenated MISRA.CHAR.TRIGRAPH Trigraph usage MISRA.CHAR.DIGRAPH Digraph usage MISRA.TOKEN.BADCOM Inappropriate character sequence in a comment MISRA.TOKEN.COMMENTED.CODE Comment appears to contain commented out source code |
| Rule 3 | Required |
MISRA.ONEDEFRULE.FUNC Global function definition in a header file MISRA.ONEDEFRULE.VAR Global variable definition in a header file MISRA.DECL.FUNC_LOCAL Function is declared locally MISRA.DECL.ARRAY_SIZE Declaration of array with unknown size MISRA.OBJ.TYPE.COMPAT Type not compatible with type of other declaration MISRA.LINKAGE.EXTERN Object or function declaration with external linkage not in header file MISRA.FUNC.STATIC.REDECL Function or object redeclaration does not include 'static' modifier MISRA.VAR.MIN.VIS Name visibility is too wide MISRA.OBJ.TYPE.IDENT Type not identical with type of other declaration MISRA.BUILTIN_NUMERIC Builtin numeric type is used MISRA.FLOAT.BIT.REPR Use of bit manipulations of floating-point values which rely on storage layout |
| Rule 4 | Required |
MISRA.LITERAL.NULL.INT NULL used as an integer value. MISRA.LITERAL.NULL.PTR Literal zero used as the null-pointer-constant. MISRA.LOGIC.OPERATOR.NOT_BOOL Operand of non-logical operator is effectively boolean MISRA.ENUM.OPERAND Expression of enum type is used in arithmetic context MISRA.CHAR.OPERAND Expression of type 'char' or 'wchar_t' is used as non-character operand |
| Rule 5 | Required |
PORTING.VAR.EFFECTS Variable used twice in one expression where one usage is subject to side-effects MISRA.CAST.UNSIGNED_BITS The result of bitwise operation on unsigned char or short is not cast back to original type MISRA.CHAR.NOT_CHARACTER 'char' is used for non-character value MISRA.SIGNED_CHAR.NOT_NUMERIC 'signed char' or 'unsigned char' is used for non-numeric value MISRA.STMT.COND.NOT_BOOLEAN Condition of if or loop statement is not a boolean expression MISRA.EXPR.COND.NOT_BOOLEAN First operand of conditional expression is not a boolean expression MISRA.PTR.ARITH Pointer is used in arithmetic or array index expression MISRA.PTR.ARITH.NOT_SAME.2008 A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand MISRA.PTR.SUB Pointer subtraction shall only be applied if pointing to same array MISRA.PTR.SUB.OBJECT Pointer subtraction shall only be applied if pointing to same object MISRA.PTR.CMP.2008 Pointer comparison using comparison operators shall only be applied if pointing to same array and within the range MISRA.PTR.CMP.OBJECT.2008 Pointer comparison using comparison operators shall only be applied if pointing to same object and within the range MISRA.PTR.TO_PTR_TO_PTR Pointer declaration has more than two levels of indirection MISRA.EXPR.PARENS.INSUFFICIENT Limited dependence required for operator precedence rules in expressions MISRA.EXPR.PARENS.REDUNDANT Limited dependence required for operator precedence rules in expressions MISRA.BITS.OPERAND Operands of bitwise operation have different underlying types MISRA.BITS.NOT_UNSIGNED Operand of bitwise operation is not unsigned integer MISRA.BITS.NOT_UNSIGNED.PREP Operand of bitwise operation is not unsigned integer MISRA.CVALUE.IMPL.CAST.CPP The value of an expression implicitly converted to a different type MISRA.CONV.INT.SIGN Implicit integral conversion changes signedness MISRA.CONV.FLOAT Implicit floating-point conversion MISRA.CONV.NUM.NARROWER Implicit numeric conversion to narrower type MISRA.CAST.FLOAT_INT Cast of floating point expression to integral type MISRA.CAST.INT_FLOAT Cast of integral expression to floating point type MISRA.CAST.FLOAT.WIDER Cast of floating point expression to a wider floating point type MISRA.CAST.INT.WIDER Cast of integral expression to a wider integral type MISRA.CAST.INT.SIGN Non-trivial integral expression is cast to type with different signedness MISRA.LOGIC.SIDEEFF Right operand in a logical 'and' or 'or' expression contains side effects MISRA.COMMA Comma operator is used MISRA.COMP.WRAPAROUND Wrap-around in a condition MISRA.ELIF.WRAPAROUND Wrap-around in #elif directive MISRA.IF.WRAPAROUND Wrap-around in #if directive NUM.OVERFLOW.DF Possible numeric overflow or wraparound MISRA.LOGIC.POSTFIX Operand in a logical 'and' or 'or' expression is not a postfix expression MISRA.INCR_DECR.OTHER Increment or decrement operator is mixed with other operators in expression MISRA.BIN_OP.OVERLOAD Comma, || or && operator overloaded MISRA.FUNC.ARRAY.PARAMS Function argument with array type decay to a pointer MISRA.CAST.PTR.VRCLASS A cast form pointer to a virtual base class to pointer to a derived class does not use 'dynamic_cast' MISRA.CAST.POLY.TYPE Cast from a polymorphic base class to a derived class MISRA.C_CAST C-style cast to non-void type MISRA.FUNC_CAST Functional notation cast different from explicit constructor call MISRA.CAST.CONST Cast operation removes const or volatile modifier from a pointer or reference MISRA.CAST.FUNC_PTR.CPP Cast converts function pointer to other pointer type MISRA.CAST.PTR.UNRELATED Object of pointer type cast to unrelated type MISRA.CAST.INT_TO_PTR Object with integer type or pointer to void cast to pointer type MISRA.CAST.PTR_TO_INT Cast between a pointer and an integral type MISRA.LOGIC.NOT_BOOL Operand of logical operation is not boolean MISRA.UMINUS.UNSIGNED Operand of unary minus is unsigned MISRA.UN_OP.OVERLOAD Unary & operator is overloaded MISRA.SIZEOF.SIDE_EFFECT Operand of sizeof has side effects MISRA.SHIFT.RANGE Right operand of shift operation is out of range - greater or equal to max bit-length of left operand, or negative |
| Rule 6 | Required |
MISRA.ASSIGN.COND Assignment operator is used in a condition MISRA.ASSIGN.SUBEXPR Assignment operator is used in a sub-expression outside a condition MISRA.FLOAT_EQUAL Floating point expression is tested for equality MISRA.NULL.STMT Null statement is not the only statement on line or comments are placed incorrectly MISRA.STMT.NO_COMPOUND The body of switch, while, do/while or for statement is not a compound statement MISRA.IF.NO_COMPOUND The body of if/else statement is not a compound statement MISRA.IF.NO_ELSE A chain of if/else-if statements is not terminated with else or is terminated with an empty else clause MISRA.SWITCH.NOT_WELL_FORMED Switch statement is not well-formed MISRA.SWITCH.LABEL A switch label belongs to nested compound statement inside switch body MISRA.SWITCH.NO_BREAK No break or throw statement at the end of switch-clause MISRA.SWITCH.NODEFAULT No default clause at the end of a switch statement MISRA.SWITCH.BOOL Condition of switch statement is boolean expression MISRA.SWITCH.NO_CASE No case-clause in a switch statement MISRA.FOR.COUNTER.FLT For loop counter has a floating point type MISRA.FOR.COUNTER.MANY Many counters in a for loop MISRA.FOR.COND.EQ ++ or -- operations are not used to change loop counter, but condition tests loop counter for equality MISRA.FOR.COND.CHANGE For loop counter is modified within the loop condition section MISRA.FOR.STMT.CHANGE For loop counter is modified within the loop statement MISRA.FOR.INCR For loop counter is modified in an inappropriate way MISRA.FOR.LOOP_CONTROL.CHANGE.COND Loop control variable is modified in condition section of a for loop MISRA.FOR.LOOP_CONTROL.CHANGE.EXPR Loop control variable is modified in expression section of a for loop MISRA.FOR.LOOP_CONTROL.NOT_BOOLEAN Loop control variable is not boolean MISRA.GOTO.NESTED Goto to a label declared in a nested compound statement MISRA.GOTO.AFTER.LABEL Unconstrained use of goto MISRA.CONTINUE.ILL Continue statement is used in an ill-formed for loop MISRA.ITER.ONETERM Iteration statement has more than one break or goto for loop termination. MISRA.RETURN.NOT_LAST Return is not the last statement in a function |
| Rule 7 | Required |
MISRA.VAR.NEEDS.CONST Variable is not modified but is declared without const qualifier MISRA.PPARAM.NEEDS.CONST Pointer parameter is not used to modify the addressed object but is not declared as a pointer to const MISRA.NS.GLOBAL Function, variable or type declaration in global namespace MISRA.NS.GLOBAL.USING Using directive or declaration in global namespace MISRA.NS.MAIN Non-global function with name 'main' is defined MISRA.NAMESPACE.UNMD Unnamed namespace in header file MISRA.NS.USING_DIR Using directive MISRA.NS.USING_DECL Multiple declarations for an identifier in the same namespace should not straddle a using-declaration for that identifier MISRA.NAMESPACE.DECL Using-declaration in header file MISRA.NAMESPACE.DIR Using-directive in header file MISRA.NS.USING.HEADER Using directive or declaration is used in a header file MISRA.PRAGMA.ASM Incorrect assembler instruction MISRA.ASM.ENCAPS Assembly language is not isolated. LOCRET.RET Function returns address of local variable LOCRET.ARG Function returns address of local variable LOCRET.GLOB Function returns address of local variable MISRA.ADDR.REF.PARAM Function returns reference to parameter passed by reference MISRA.ADDR.REF.PARAM.PTR Function returns address of parameter passed by reference MISRA.FUNC.RECUR Recursive function |
| Rule 8 | Required |
MISRA.DECL.MANY_DCLS More than one declarator in one declaration MISRA.SAME.DEFPARAMS Overriding virtual function and the function it overrides have different default arguments MISRA.FUNC.VARARG Function with variable number of arguments MISRA.FUNC.PARAMS.IDENT Identifiers used in declaration and definition of function are not identical FUNCRET.GEN Non-void function does not return value MISRA.FUNC.ADDR Address of a function is used without & operator UNINIT.CTOR.MIGHT Uninitialized Variable in Constructor - possible UNINIT.CTOR.MUST Uninitialized Variable in Constructor UNINIT.HEAP.MIGHT Uninitialized Heap Use - possible UNINIT.HEAP.MUST Uninitialized Heap Use UNINIT.STACK.ARRAY.MIGHT Uninitialized Array - possible UNINIT.STACK.ARRAY.MUST Uninitialized Array UNINIT.STACK.ARRAY.PARTIAL.MUST Partially Uninitialized Array UNINIT.STACK.MIGHT Uninitialized Variable - possible UNINIT.STACK.MUST Uninitialized Variable MISRA.INIT.BRACES Incorrect initializer braces placement. MISRA.ENUM.INIT Non-first enumerator is explicitly initialized, but not all elements are explicitly initialized. |
| Rule 9 | Required |
MISRA.CONST.RET.NON_CONST Constant member function returns non-const pointer to member variable MISRA.RET.REF.NON_CONST Member function returns non-const handle to member variable MISRA.MEMB.NON_CONST Non-const member function does not change any member variables MISRA.MEMB.NON_STATIC Non-static member function does not use other non-static members of the same class MISRA.UNION Union is used MISRA.BITFIELD.TYPE.CPP Type of bit-field is neither bool, nor signed/unsigned integer MISRA.FIELD.BIT.ENUM Bit-field has enum type. MISRA.BITFIELD.SIGNED Length of a named signed bit-field is less than 2 |
| Rule 10 | Advisory |
MISRA.DERIVE.VIRTUAL Class is derived from virtual base MISRA.VIRTUAL.BASE.DIAMOND Base class is used as virtual not in diamond hierarchy MISRA.BASE.VIRTUAL.NOTVIRTUAL Base class is used as both virtual and not virtual in inheritance hierarchy MISRA.BASE.IDS.UNIQUE Member name is used twice in inheritance hierarchy MISRA.BASE.MANYDEFS Both overriding and overridden virtual functions have definitions MISRA.VIRTUAL.NOVIRTUAL Overriding virtual function declared with no 'virtual' keyword MISRA.PUREVIRT.OVRD Pure virtual function overrides a non pure virtual function |
| Rule 11 | Required |
MISRA.MEMB.NOT_PRIVATE Member variable in non-POD class is not private |
| Rule 12 | Required |
MISRA.CTOR.DYNAMIC Object's dynamic type is used from the body of its constructor MISRA.DTOR.DYNAMIC Object's dynamic type is used from the body of its destructor MISRA.CTOR.BASE Constructor does not explicitly call constructor of its base class MISRA.CTOR.NOT_EXPLICIT Constructor with one argument of built-in type is not declared 'explicit' MISRA.COPYASSIGN.ABSTRACT Copy assignment should be declared protected or private in an abstract class |
| Rule 14 | Required |
MISRA.GENFU.ASSOC Generic function is declared in an associated namespace MISRA.COPY.CSTR.TMPL Class has a template constructor with a single generic parameter, but has no copy constructor defined MISRA.COPYASSIGN.TMPL A copy ssignment operator should be defined when class has a template copy assignment operator with a single generic parameter MISRA.TEMPLMEM.NOQUAL In an instantiated template a member declared in a dependant base is used without a qualificator or 'this' MISRA.FUNC.DECL.AFTERUSE Function chosen by overload resolution when instantiating a template is declared after its usage MISRA.SPEC.ILL Explicit instantiation of a template makes the code ill-formed MISRA.SPEC.SAMEFILE Template specialization and its primary template are declared in different files MISRA.FUNC.SPEC.OVRLD Viable function set for a function call contains an overloaded template and its explicit specialization MISRA.FUNC.SPEC.NOTSPEC Viable function set for a function call contains both specializations and non-specializations |
| Rule 15 | Advisory |
MISRA.THROW.PTR Exception object is a pointer MISRA.TRY.JUMP Control can be transferred into a try block with goto or switch statement MISRA.THROW.NULL NULL is thrown explicitly MISRA.THROW.EMPTY Empty throw expression does not belong to a catch block MISRA.CATCH.ALL No ellipsis exception handler in a try-catch block MISRA.CTOR.TRY.NON_STATIC Function try/catch block of constructor or destructor references non-static members MISRA.CATCH.BY_VALUE Exception object of class type is caught by value MISRA.CATCH.WRONGORD Handler for a base exception class precedes to a handler for a derived exception class in a try-catch block MISRA.CATCH.NOALL Ellipsis exception handler is not the last one in a try-catch block MISRA.DECL.EXCPT.SPEC Function is declared with different exception specifications MISRA.DTOR.THROW Throw in destructor MISRA.TERMINATE terminate() function is called explicitly |
| Rule 16 | Required |
MISRA.INCL.INSIDE Include directive preceded by a preprocessor output token MISRA.DEFINE.NOTGLOBAL Define not at the global level MISRA.UNDEF.NOTGLOBAL Undef not at the global level MISRA.UNDEF Undef usage MISRA.DEFINE.FUNC Function-like macro definition MISRA.EXPANSION.DIRECTIVE Directive-like tokens within a macro argument MISRA.DEFINE.NOPARS Macro parameter with no parentheses MISRA.ELIF.UNDEF Undefined macros in #elif directive MISRA.IF.UNDEF Undefined macros in #if directive MISRA.USE.UNKNOWNDIR Unknown preprocessor directive is used MISRA.ELIF.DEFINED Incorrect 'defined' usage in #elif directive MISRA.IF.DEFINED Incorrect 'defined' usage in #if directive MISRA.ELIF.OTHERFILE #elif in an improper file MISRA.ELSE.OTHERFILE #else in an improper file MISRA.ENDIF.OTHERFILE #endif in an improper file MISRA.USE.DEFINE Non-guarding macro definition MISRA.USE.EXPANSION Macro expansion MISRA.USE.WRONGDIR Improper preprocessor directive MISRA.DEFINE.BADEXP.CPP Inappropriate macro expansion in a C++ source MISRA.INCGUARD Include guard is not provided MISRA.INCL.SYMS Non-standard characters in header file names MISRA.INCL.BAD Non-standard include directive MISRA.DEFINE.SHARP.MANY Several # or ## operators in a macro definition MISRA.DEFINE.SHARP # or ## operator in a macro definition MISRA.PRAGMA Non-documented pragma directive |
| Rule 17 | Required |
MISRA.DEFINE.WRONGNAME Usage of a name from the standard library for naming a macro MISRA.DEFINE.WRONGNAME.UNDERSCORE Usage of a reserved name for naming a macro MISRA.UNDEF.WRONGNAME Undefinition of a name from the standard library MISRA.UNDEF.WRONGNAME.UNDERSCORE Undefinition of a reserved name MISRA.STDLIB.WRONGNAME Reused name of standard library macro, object or function MISRA.STDLIB.WRONGNAME.UNDERSCORE Usage of a reserved name for naming a language entity MISRA.EXPANSION.UNSAFE Unsafe macro usage MISRA.STDLIB.LONGJMP Use of setjmp macro or longjmp function |
| Rule 18 | Required |
MISRA.EXPANSION.UNSAFE Unsafe macro usage MISRA.INCL.UNSAFE Unsafe header inclusion MISRA.STDLIB.ATOI Use of 'atof', 'atoi' or 'atol' from library stdlib.h MISRA.STDLIB.ABORT Use of 'abort', 'exit', 'getenv' or 'system' from library stdlib.h MISRA.STDLIB.TIME Use of the time handling functions of library time.h MISRA.STDLIB.CSTRING Function from 'cstring' library is used MISRA.STDLIB.CSTRING.MACRO Macro from 'cstring' library is used MISRA.STDLIB.MEMORY Use of dynamic heap memory allocation MISRA.STDLIB.SIGNAL Use of the signal handling facilities of signal.h |
| Rule 19 | Required |
MISRA.EXPANSION.UNSAFE Unsafe macro usage MISRA.STDLIB.ERRNO Use of error indicator 'errno' |
| Rule 27 | Required |
MISRA.INCL.UNSAFE Unsafe header inclusion MISRA.STDLIB.STDIO Use of input/output library stdio.h in production code |
Support Summary
Total supported: 196
Total of not statically verifiable rules: 12
Total of statically verifiable rules not supported: 20
MISRA C++ coverage: 91% (excludes rules that are not statically verifiable)
"MISRA", "MISRA C" and "MISRA C++" are registered trademarks of The MISRA Consortium Limited.