MISRA C++:2023 rules

Guideline Category Checker name and description
Dir. 0.3.1 Required

Dir. 0.3.2 Required

Dir. 5.7.2 Required

MISRA.TOKEN.COMMENTED.CODE  Comment appears to contain commented out source code

Dir. 15.8.1 Required

CL.SELF-ASSIGN  Use of free memory (double free) - in operator=

Rule 0.0.1 Required

UNREACH.ENUM  Code is unreachable due to the possible value(s) of an enum

UNREACH.GEN  Unreachable code

UNREACH.RETURN  Unreachable Void Return

UNREACH.SIZEOF  Architecture-related unreachable code

Rule 0.0.2 Advisory

INVARIANT_CONDITION.GEN  Invariant expression in a condition

INVARIANT_CONDITION.UNREACH  Invariant expression in a condition

Rule 0.1.1 Advisory

VA_UNUSED.GEN  Value is Never Used after Assignment

VA_UNUSED.INIT  Value is Never Used after Initialization

Rule 0.1.2 Required

MISRA.FUNC.UNUSEDRET  Return value of a non-void function is not used

Rule 0.2.1 Advisory

LV_UNUSED.GEN  Local variable unused

Rule 0.2.2 Required

MISRA.FUNC.UNUSEDPAR  Formal parameter of a non-virtual function is not used

Rule 0.2.3 Required

Rule 0.2.4 Advisory

UNUSED.FUNC.GEN  Function defined but not used

Rule 4.1.1 Required

Rule 4.1.2 Advisory

MISRA.TOKEN.OCTAL.ESCAPE  Usage of octal escape sequences

MISRA.TOKEN.OCTAL.INT  Usage of octal integer constants

Rule 4.1.3 Required

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.CONV.FLOAT  Implicit floating-point conversion

MISRA.DECL.EXCPT.SPEC  Function is declared with different exception specifications

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.INCL.UNSAFE  Unsafe header inclusion

MISRA.SPEC.SAMEFILE  Template specialization and its primary template are declared in different files

MISRA.STDLIB.CSTRING.MACRO  Macro from 'cstring' library is used

MISRA.TOKEN.WRONGESC.CPP.2008  Incorrect escape sequence in a literal

Rule 4.6.1 Required

Rule 5.0.1 Required

MISRA.CHAR.TRIGRAPH  Trigraph usage

Rule 5.7.1 Required

MISRA.TOKEN.BADCOM  Inappropriate character sequence in a comment

Rule 5.7.3 Required

Rule 5.10.1 Required

Rule 5.13.1 Required

Rule 5.13.2 Required

Rule 5.13.3 Required

MISRA.TOKEN.OCTAL.INT  Usage of octal integer constants

Rule 5.13.4 Required

MISRA.LITERAL.UNSIGNED.SUFFIX  Unsigned integer literal without 'U' suffix

Rule 5.13.5 Required

Rule 5.13.6 Required

Rule 5.13.7 Required

MISRA.STRINGS.CONCAT  Narrow and wide string literals concatenated

Rule 6.0.1 Required

MISRA.DECL.FUNC_LOCAL  Function is declared locally

Rule 6.0.2 Advisory

MISRA.DECL.ARRAY_SIZE  Declaration of array with unknown size

Rule 6.0.3 Advisory

MISRA.NS.GLOBAL  Function, variable or type declaration in global namespace

MISRA.NS.GLOBAL.USING  Using directive or declaration in global namespace

Rule 6.0.4 Required

MISRA.NS.MAIN  Non-global function with name 'main' is defined

Rule 6.2.1 Required

Rule 6.2.2 Required

MISRA.OBJ.TYPE.COMPAT  Type not compatible with type of other declaration

Rule 6.2.3 Required

Rule 6.2.4 Required

MISRA.ONEDEFRULE.FUNC  Global function definition in a header file

MISRA.ONEDEFRULE.VAR  Global variable definition in a header file

Rule 6.4.1 Required

MISRA.VAR.HIDDEN  Identifier declared in an inner scope hides identifier in outer scope

Rule 6.4.2 Required

MISRA.BASE.IDS.UNIQUE  Member name is used twice in inheritance hierarchy

Rule 6.4.3 Required

MISRA.TEMPLMEM.NOQUAL  In an instantiated template a member declared in a dependant base is used without a qualificator or 'this'

Rule 6.5.1 Advisory

MISRA.LINKAGE.EXTERN  Object or function declaration with external linkage not in header file

Rule 6.5.2 Advisory

Rule 6.7.1 Required

Rule 6.7.2 Required

Rule 6.8.1 Required

LOCRET.RET  Function returns address of local variable

UFM.DEREF.MUST  Use of Freed Memory by Pointer

UFM.FFM.MIGHT  Use of free memory (double free) - possible

UFM.FFM.MUST  Freeing Freed Memory

UFM.RETURN.MIGHT  Use of freed memory (return) - possible

UFM.RETURN.MUST  Use of Freed Memory on Return

UFM.USE.MIGHT  Use of free memory - possible

UFM.USE.MUST  Use of Freed Memory

Rule 6.8.2 Mandatory

LOCRET.RET  Function returns address of local variable

Rule 6.8.3 Required

LOCRET.ARG  Function returns address of local variable

LOCRET.GLOB  Function returns address of local variable

Rule 6.8.4 Advisory

Rule 6.9.1 Required

MISRA.OBJ.TYPE.IDENT  Type not identical with type of other declaration

Rule 6.9.2 Advisory

MISRA.BUILTIN_NUMERIC  Builtin numeric type is used

Rule 7.0.1 Required

CXX.BITOP.BOOL_OPERAND  Potential logic error: Boolean expressions should not be used directly as bitwise operator arguments. Consider using logical operators instead.

MISRA.LOGIC.OPERATOR.NOT_BOOL  Operand of non-logical operator is effectively boolean

Rule 7.0.2 Required

PORTING.CMPSPEC.TYPE.BOOL  Assignment to a 'bool' type is larger than 1 byte

Rule 7.0.3 Required

MISRA.CHAR.NOT_CHARACTER  'char' is used for non-character value

Rule 7.0.4 Required

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.BITS.OPERAND  Operands of bitwise operation have different underlying types

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 7.0.5 Required

MISRA.CAST.FLOAT_INT  Cast of floating point expression to integral type

MISRA.CAST.INT.SIGN  Non-trivial integral expression is cast to type with different signedness

MISRA.CAST.INT_FLOAT  Cast of integral expression to floating point type

MISRA.CONV.INT.SIGN  Implicit integral conversion changes signedness

Rule 7.0.6 Required

MISRA.CHAR.OPERAND  Expression of type 'char' or 'wchar_t' is used as non-character operand

MISRA.ENUM.OPERAND  Expression of enum type is used in arithmetic context

Rule 7.11.1 Required

MISRA.LITERAL.NULL.INT  NULL used as an integer value.

MISRA.LITERAL.NULL.PTR  Literal zero used as the null-pointer-constant.

Rule 7.11.2 Required

MISRA.FUNC.ARRAY.PARAMS  Function argument with array type decay to a pointer

Rule 7.11.3 Required

MISRA.CAST.FUNC_PTR.CPP  Cast converts function pointer to other pointer type

MISRA.CAST.INT_TO_PTR  Object with integer type or pointer to void cast to pointer type

MISRA.CAST.PTR.UNRELATED  Object of pointer type cast to unrelated type

Rule 8.0.1 Advisory

MISRA.DEFINE.NOPARS  Macro parameter with no parentheses

MISRA.EXPR.PARENS.REDUNDANT  Limited dependence required for operator precedence rules in expressions

MISRA.LOGIC.POSTFIX  Operand in a logical 'and' or 'or' expression is not a postfix expression

Rule 8.1.1 Required

Rule 8.1.2 Advisory

AUTOSAR.LAMBDA.IMPLICIT_CAPTURE  Variables shall not be implicitly captured in a lambda expression

Rule 8.2.1 Required

MISRA.CAST.PTR.VRCLASS  A cast form pointer to a virtual base class to pointer to a derived class does not use 'dynamic_cast'

Rule 8.2.2 Required

MISRA.C_CAST  C-style cast to non-void type

MISRA.FUNC_CAST  Functional notation cast different from explicit constructor call

Rule 8.2.3 Required

MISRA.CAST.CONST  Cast operation removes const or volatile modifier from a pointer or reference

Rule 8.2.4 Required

MISRA.CAST.FUNC_PTR.CPP  Cast converts function pointer to other pointer type

Rule 8.2.5 Required

AUTOSAR.CAST.REINTERPRET  reinterpret_cast shall not be used

Rule 8.2.6 Required

MISRA.CAST.INT_TO_PTR  Object with integer type or pointer to void cast to pointer type

Rule 8.2.7 Advisory

MISRA.CAST.PTR_TO_INT  Cast between a pointer and an integral type

Rule 8.2.8 Required

Rule 8.2.9 Required

Rule 8.2.10 Required

MISRA.FUNC.RECUR  Recursive function

Rule 8.2.11 Required

Rule 8.3.1 Advisory

MISRA.UMINUS.UNSIGNED  Operand of unary minus is unsigned

Rule 8.3.2 Advisory

Rule 8.7.1 Required

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

Rule 8.7.2 Required

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

Rule 8.9.1 Required

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

Rule 8.14.1 Advisory

MISRA.LOGIC.SIDEEFF  Right operand in a logical 'and' or 'or' expression contains side effects

Rule 8.18.1 Mandatory

MISRA.ASSIGN.OVERLAP  Object is assigned to an overlapping object

Rule 8.18.2 Advisory

MISRA.ASSIGN.COND  Assignment operator is used in a condition

MISRA.ASSIGN.SUBEXPR  Assignment operator is used in a sub-expression outside a condition

Rule 8.19.1 Advisory

MISRA.COMMA  Comma operator is used

Rule 8.20.1 Advisory

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

Rule 9.2.1 Required

Rule 9.3.1 Required

MISRA.IF.NO_COMPOUND  The body of if/else statement is not a compound statement

MISRA.STMT.NO_COMPOUND  The body of switch, while, do/while or for statement is not a compound statement

Rule 9.4.1 Required

MISRA.IF.NO_ELSE  A chain of if/else-if statements is not terminated with else or is terminated with an empty else clause

Rule 9.4.2 Required

MISRA.SWITCH.BOOL  Condition of switch statement is boolean expression

MISRA.SWITCH.LABEL  A switch label belongs to nested compound statement inside switch body

MISRA.SWITCH.NOT_WELL_FORMED  Switch statement is not well-formed

MISRA.SWITCH.NO_CASE  No case-clause in a switch statement

Rule 9.5.1 Advisory

MISRA.FOR.COND.CHANGE  For loop counter is modified within the loop condition section

MISRA.FOR.COUNTER.FLT  For loop counter has a floating point type

MISRA.FOR.COUNTER.MANY  Many counters in a for loop

MISRA.FOR.INCR  For loop counter is modified in an inappropriate way

MISRA.FOR.STMT.CHANGE  For loop counter is modified within the loop statement

Rule 9.5.2 Required

Rule 9.6.1 Advisory

AUTOSAR.GOTO  The goto statement shall not be used

Rule 9.6.2 Required

MISRA.GOTO.NESTED  Goto to a label declared in a nested compound statement

Rule 9.6.3 Required

MISRA.GOTO.AFTER.LABEL  Unconstrained use of goto

Rule 9.6.4 Required

Rule 9.6.5 Required

FUNCRET.GEN  Non-void function does not return value

RETVOID.GEN  Non-void function returns void value

Rule 10.0.1 Advisory

MISRA.DECL.MANY_DCLS  More than one declarator in one declaration

Rule 10.1.1 Advisory

MISRA.CONST.RET.NON_CONST  Constant member function returns non-const pointer to member variable

MISRA.PPARAM.NEEDS.CONST  Pointer parameter is not used to modify the addressed object but is not declared as a pointer to const

MISRA.RET.REF.NON_CONST  Member function returns non-const handle to member variable

Rule 10.1.2 Required

CERT.EXPR.VOLATILE.ADDR.PARAM  Do not pass a volatile object to a function through a nonvolatile pointer

Rule 10.2.1 Required

Rule 10.2.2 Advisory

Rule 10.2.3 Required

Rule 10.3.1 Advisory

MISRA.NAMESPACE.UNMD  Unnamed namespace in header file

Rule 10.4.1 Required

AUTOSAR.ASM  The asm declaration shall not be used

Rule 11.3.1 Advisory

AUTOSAR.ARRAY.CSTYLE  C-style arrays shall not be used

Rule 11.3.2 Advisory

MISRA.PTR.TO_PTR_TO_PTR  Pointer declaration has more than two levels of indirection

Rule 11.6.1 Advisory

Rule 11.6.2 Mandatory

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

Rule 11.6.3 Required

MISRA.ENUM.IMPLICIT.VAL.NON_UNIQUE.2012  Implicit enumerator value is not unique

Rule 12.2.1 Advisory

Rule 12.2.2 Required

Rule 12.2.3 Required

MISRA.BITFIELD.SIGNED  Length of a named signed bit-field is less than 2

Rule 12.3.1 Required

MISRA.UNION  Union is used

Rule 13.1.1 Advisory

MISRA.DERIVE.VIRTUAL  Class is derived from virtual base

Rule 13.1.2 Required

MISRA.BASE.VIRTUAL.NOTVIRTUAL  Base class is used as both virtual and not virtual in inheritance hierarchy

Rule 13.3.1 Required

AUTOSAR.MEMB.VIRTUAL.SPEC  Virtual function declaration shall contain exactly one of the three specifiers: (1) virtual, (2) override, (3) final.

Rule 13.3.2 Required

Rule 13.3.3 Required

MISRA.FUNC.PARAMS.IDENT  Identifiers used in declaration and definition of function are not identical

Rule 13.3.4 Required

AUTOSAR.VIRTUAL.PTR_COMPARE  A pointer to member virtual function shall only be tested for equality with null-pointer-constant

Rule 14.1.1 Advisory

Rule 15.0.1 Required

Rule 15.0.2 Advisory

Rule 15.1.1 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

Rule 15.1.2 Advisory

MISRA.CTOR.BASE  Constructor does not explicitly call constructor of its base class

Rule 15.1.3 Required

MISRA.CTOR.NOT_EXPLICIT  Constructor with one argument of built-in type is not declared 'explicit'

Rule 15.1.4 Advisory

Rule 15.1.5 Required

Rule 16.5.1 Required

Rule 16.5.2 Required

MISRA.UN_OP.OVERLOAD  Unary & operator is overloaded

Rule 16.6.1 Advisory

Rule 17.8.1 Required

MISRA.FUNC.SPEC.OVRLD  Viable function set for a function call contains an overloaded template and its explicit specialization

Rule 18.1.1 Required

MISRA.THROW.PTR  Exception object is a pointer

Rule 18.1.2 Required

MISRA.THROW.EMPTY  Empty throw expression does not belong to a catch block

Rule 18.3.1 Advisory

MISRA.CATCH.ALL  No ellipsis exception handler in a try-catch block

Rule 18.3.2 Required

MISRA.CATCH.BY_VALUE  Exception object of class type is caught by value

Rule 18.3.3 Required

MISRA.CTOR.TRY.NON_STATIC  Function try/catch block of constructor or destructor references non-static members

Rule 18.4.1 Required

Rule 18.5.1 Advisory

AUTOSAR.EXCPT.NOEXCPT_THROW  If a function is declared to be noexcept, noexcept(true) or noexcept(<true condition>), then it shall not exit with an exception

Rule 18.5.2 Advisory

MISRA.TERMINATE  terminate() function is called explicitly

Rule 19.0.1 Required

MISRA.USE.UNKNOWNDIR  Unknown preprocessor directive is used

Rule 19.0.2 Required

MISRA.DEFINE.FUNC  Function-like macro definition

Rule 19.0.3 Advisory

MISRA.INCL.INSIDE  Include directive preceded by a preprocessor output token

Rule 19.0.4 Advisory

Rule 19.1.1 Required

MISRA.ELIF.DEFINED  Incorrect 'defined' usage in #elif directive

MISRA.IF.DEFINED  Incorrect 'defined' usage in #if directive

Rule 19.1.2 Required

MISRA.ELIF.OTHERFILE  #elif in an improper file

MISRA.ELSE.OTHERFILE  #else in an improper file

MISRA.ENDIF.OTHERFILE  #endif in an improper file

Rule 19.1.3 Required

MISRA.ELIF.UNDEF  Undefined macros in #elif directive

MISRA.IF.UNDEF  Undefined macros in #if directive

Rule 19.2.1 Required

MISRA.INCGUARD  Include guard is not provided

Rule 19.2.2 Required

MISRA.INCL.BAD  Non-standard include directive

Rule 19.2.3 Required

MISRA.INCL.SYMS  Non-standard characters in header file names

Rule 19.3.1 Advisory

MISRA.DEFINE.SHARP  # or ## operator in a macro definition

Rule 19.3.2 Required

MISRA.DEFINE.SHARP.ORDER.2012  Unspecified order of evaluation of multiple '#' or '##'

Rule 19.3.3 Required

MISRA.DEFINE.SHARP.REPLACE.2012  A macro parameter used as an operand to the '#' or '##' operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators

Rule 19.3.4 Required

MISRA.DEFINE.NOPARS  Macro parameter with no parentheses

Rule 19.3.5 Required

MISRA.EXPANSION.DIRECTIVE  Directive-like tokens within a macro argument

Rule 19.6.1 Advisory

MISRA.PRAGMA.ASM  Incorrect assembler instruction

PORTING.PRAGMA.ALIGN  #pragma align usage

PORTING.PRAGMA.PACK  #pragma pack usage

Rule 21.2.1 Required

MISRA.STDLIB.ATOI  Use of 'atof', 'atoi' or 'atol' from library stdlib.h

Rule 21.2.2 Required

MISRA.STDLIB.CSTRING  Function from 'cstring' library is used

Rule 21.2.3 Required

MISRA.STDLIB.SYSTEM.2012_AMD2  Use of 'system' from library stdlib.h

Rule 21.2.4 Required

Rule 21.6.1 Advisory

MISRA.STDLIB.MEMORY  Use of dynamic heap memory allocation

Rule 21.6.2 Required

MISRA.STDLIB.MEMORY  Use of dynamic heap memory allocation

Rule 21.6.3 Required

Rule 21.6.4 Required

AUTOSAR.OP.DELETE.MISSING_VERSION  If a project has sized or unsized version of operator "delete" globally defined, then both sized and unsized versions shall be defined

Rule 21.6.5 Required

CERT.EXPR.DELETE_PTR.INCOMPLETE_TYPE  Do not delete a pointer to an incomplete type

Rule 21.10.1 Required

MISRA.FUNC.VARARG  Function with variable number of arguments

Rule 21.10.2 Required

MISRA.STDLIB.LONGJMP  Use of setjmp macro or longjmp function

Rule 21.10.3 Required

MISRA.STDLIB.SIGNAL  Use of the signal handling facilities of signal.h

Rule 22.3.1 Required

Rule 22.4.1 Required

Rule 23.11.1 Advisory

Rule 24.5.1 Required

Rule 24.5.2 Required

Rule 25.5.1 Required

AUTOSAR.SETLOCALE  The library <clocale> (locale.h) and the setlocale function shall not be used

Rule 25.5.2 Mandatory

CXX.STDLIB.ILLEGAL_WRITE  The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type

Rule 25.5.3 Mandatory

CXX.STDLIB.ILLEGAL_REUSE  The pointer returned by the Standard Library functions asctime and similar shall not be used following a subsequent call to the same function

Rule 26.3.1 Advisory

AUTOSAR.VECTOR.BOOL  The std::vector<bool> specialization shall not be used

Rule 28.3.1 Required

Rule 28.6.1 Required

AUTOSAR.STDLIB.MOVE.CONST  The std::move shall not be used on objects declared const or const&

Rule 28.6.2 Required

AUTOSAR.FORWARD  Forwarding values to other functions shall be done via: (1) std::move if the value is an rvalue reference, (2) std::forward if the value is forwarding reference

Rule 28.6.3 Required

Rule 28.6.4 Required

Rule 30.0.1 Required

MISRA.STDLIB.STDIO  Use of input/output library stdio.h in production code

Rule 30.0.2 Required

Support Summary

Total supported: 125

Total of not statically verifiable rules: 4

Total of statically verifiable rules not supported: 50

MISRA C++ coverage: 70% (excludes rules that are not statically verifiable)

"MISRA", "MISRA C" and "MISRA C++" are registered trademarks of The MISRA Consortium Limited. ​