MISRA 2008

MISRA 2008

Below are the list of MISRA 2008 rules supported by Embold:

RulesRule Name
Rule 0-1-1A project shall NOt contain unreachable code.
Rule 0-1-2A project shall NOt contain infeasible paths.
Rule 0-1-3A project shall NOt contain unused variables.
Rule 0-1-5A project shall NOt contain unused type declarations.
Rule 0-1-7The value returned by a function having a NOn-void return type that is NOt an overloaded operator shall always be used.
Rule 0-1-9There shall be NO dead code.
Rule 0-1- 10Every defined function shall be called at least once.
Rule 0-1- 11There shall be NO unused parameters (named or unnamed) in NOn-virtual functions.
Rule 2-3-1Trigraphs shall NOt be used.
Rule 2-5-1Digraphs should NOt be used.
Rule 2-7-1The character sequence /* shall NOt be used within a C-style comment.
Rule 2-7-2Sections of code shall NOt be “commented out” using C-style comments.
Rule 2-7-3Sections of code should NOt be “commented out” using C++ comments.
Rule 2-10-2Identifiers declared in an inner scope shall NOt hide an identifier declared
in an outer scope.
Rule 2-10-3A typedef name (including qualification, if any) shall be a unique identifier.
Rule 2-10-4The identifier name of a NOn-member object or function with static
storage duration should NOt be reused.
Rule 2-10-5If an identifier refers to a type, it shall NOt also refer to an object or a
function in the same scope.
Rule 2-13-1Only those escape sequences that are defined in ISO/IEC 14882:2003 shall be used.
Rule 2-13-2Octal constants (other than zero) and octal escape sequences (other than “\0”) shall NOt be used.
Rule 2-13-3A “U ” suffix shall be applied to all octal or hexadecimal integer literals of
unsigned type.
Rule 2-13-4Literal suffixes shall be upper case.
Rule 2-13-5Narrow and wide string literals shall NOt be concatenated.
Rule 3-1-3When an array is declared, its size shall either be stated explicitly or defined implicitly by initialization.
Rule 3-2-1All declarations of an object or function shall have compatible types.
Rule 3-2-2The One Definition Rule shall NOt be violated.
Rule 3-2-3A type, object or function that is used in multiple translation units shall be declared in one and only one file.
Rule 3-2-4An identifier with external linkage shall have exactly one definition.
Rule 3-3-2If a function has internal linkage then all re-declarations shall include the static storage class specifier.
Rule 5-Rule 5-0-1
0-1
The value of an expression shall be the same under any order of evaluation that the standard permits.
Rule 5-0-2Limited dependence should be placed on C++ operator precedence rules in expressions.
Rule 5-0-4An implicit integral conversion shall NOt change the signedness of the underlying type.
Rule 5-0-5There shall be NO implicit floating-integral conversions.
Rule 5-0-6An implicit integral or floating-point conversion shall NOt reduce the size of the underlying type
Rule 5-0-8An explicit integral or floating-point conversion shall NOt increase the size of the underlying type of a cvalue expression.
Rule 5-0-9An explicit integral conversion shall NOt change the signedness of the underlying type of a cvalue expression.
Rule 5-0- 13The condition of an if‑statement and the condition of an iteration‑statement shall have type bool .
Rule 5-0- 17Subtraction between pointers shall only be applied to pointers that address elements of the same array.
Rule 5-0- 18>, >=, <, <= shall NOt be applied to objects of pointer type, except where they point to the same array.
Rule 5-0- 21Bitwise operators shall only be applied to operands of unsigned underlying type.
Rule 5-2-3Casts from a base class to a derived class should NOt be performed on polymorphic types.
Rule 5-2-4C-style casts (other than void casts) and functional NOtation casts (other than explicit constructor calls) shall NOt be used.
Rule 5-2-5A cast shall NOt remove any const or volatile qualification from the type
of a pointer or reference.
Rule 5-2-6A cast shall NOt convert a pointer to a function to any other pointer type, including a pointer to function type.
Rule 5-2-7An object with pointer type shall NOt be converted to an unrelated pointer type, either directly or indirectly.
Rule 5-2-8An object with integer type or pointer to void type shall NOt be converted to an object with pointer type.
Rule 5-2-9A cast should NOt convert a pointer type to an integral type.
Rule 5-2- 12An identifier with array type passed as a function argument shall NOt decay to a pointer.
Rule 5-3-4Evaluation of the operand to the sizeof operator shall NOt contain side effects.
Rule 5-14-1The right hand operand of a logical && or || operator shall NOt contain side effects.
Rule 5-18-1The comma operator shall NOt be used.
Rule 6-3-1The statement forming the body of a switch, while, do... while or for statement shall be a compound statement.
Rule 6-4-2All if ... else if constructs shall be terminated with an else clause.
Rule 6-4-3A switch statement shall be a well‑formed switch statement.
Rule 6-4-5An unconditional throw or break statement shall terminate every NOnempty switch‑clause.
Rule 6-4-6The final clause of a switch statement shall be the default‑ clause.
Rule 6-4-7The condition of a switch statement shall NOt have bool type
Rule 6-4-8Every switch statement shall have at least one case‑clause.
Rule 6-5-3The loop‑counter shall NOt be modified within condition or statement.
Rule 6-5-5A loop‑control‑variable other than the loop‑counter shall NOt be modified within condition or expression.
Rule 6-5-6A loop‑control‑variable other than the loop‑counter which is modified in statement shall have type bool .
Rule 6-6-3The continue statement shall only be used within a well‑formed for loop.
Rule 6-6-4For any iteration statement there shall be NO more than one break or goto statement used for loop termination.
Rule 6-6-5A function shall have a single point of exit at the end of the function.
Rule 7-5-3A function shall NOt return a reference or a pointer to a parameter that is passed by reference or const reference.
Rule 7-5-4Functions should NOt call themselves, either directly or indirectly.
Rule 8-4-3All exit paths from a function with NOn-void return type shall have an explicit return statement with an expression.
Rule 8-5-1All variables shall have a defined value before they are used.
Rule 9-3-1const member functions shall NOt return NOn-const pointers or references to class‑data.
Rule 9-5-1Unions shall NOt be used.
Rule 10- 1-1Classes should NOt be derived from virtual bases.
Rule 10- 3-2Each overriding virtual function shall be declared with the virtual keyword.
Rule 15- 3-2There should be at least one exception handler to catch all otherwise unhandled exceptions
Rule 15- 3-5A class type exception shall always be caught by reference.
Rule 15- 5-1A class destructor shall NOt exit with an exception.
Rule 16- 0-1#include directives in a file shall only be preceded by other preprocessor directives or comments.
Rule 16- 0-8If the # token appears as the first token on a line, then it shall be immediately followed by a preprocessing token.
Rule 16- 2-1The pre-processor shall only be used for file inclusion and include guards.
Rule 16- 2-2C++ macros shall only be used for include guards, type qualifiers, or storage class specifiers.
Rule 16- 2-3Include guards shall be provided.
Rule 16- 2-4The ′,″,/* or // characters shall NOt occur in a header file name.
Rule 16- 2-5The \ character should NOt occur in a header file name.
Rule 16- 2-6The #include directive shall be followed by either a or
″filename″ sequence
Rule 16- 3-1There shall be at most one occurrence of the # or ## operators in a single macro definition.
Rule 16- 3-2The # and ## operators should NOt be used.
Rule 17- 0-1Reserved identifiers, macros and functions in the standard library shall NOt be defined, redefined or undefined.
Rule 17- 0-2The names of standard library macros and objects shall NOt be reused
Rule 17- 0-5The setjmp macro and the longjmp function shall NOt be used.
Rule 18- 0-1The C library shall NOt be used.
Rule 18- 0-2The library functions atof, atoi and atol from library
shall NOt be used.
Rule 18- 0-3The library functions abort, exit, getenv and system from library shall NOt be used
Rule 18- 0-4The time handling functions of library shall NOt be used.
Rule 18- 0-5The unbounded functions of library shall NOt be used.
Rule 18- 2-1The macro offsetof shall NOt be used.
Rule 18- 4-1Dynamic heap memory allocation shall NOt be used.
Rule 18- 7-1The signal handling facilities of shall NOt be used.
Rule 19- 3-1The error indicator errNO shall NOt be used.
Rule 27- 0-1The stream input/output library shall NOt be used.
Rule 0-1- 12There shall be NO unused parameters (named or unnamed) in the set of parameters for a virtual function and all the functions that override it.
Rule 3-9-1The types used for an object, a function return type, or a function parameter shall be token-for-token identical in all declarations and redeclarations.
Rule 3-9-1A pointer operand and any pointer resulting from pointer arithmetic using that operand shall both address elements of the same array.
Rule 5-19-1Evaluation of constant unsigned integer expressions should NOt lead to wrap-around.
Rule 6-4-1The else keyword shall be followed by either a compound statement, or aNOther if statement.
Rule 6-4-4A switch‑label shall only be used when the most closely- enclosing compound statement is the body of a switch statement.
Rule 7-1-2A pointer or reference parameter in a function shall be declared as pointer to const or reference to const if the corresponding object is NOt
modified.
Rule 7-5-1A function shall NOt return a reference or a pointer to an automatic variable (including parameters), defined within the function.
Rule 7-5-2The 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.
Rule 10- 3-3A virtual function shall only be overridden by a pure virtual function if it is itself declared as pure virtual.
Rule 11- 0-1Member data in NOn-POD class types shall be private.
Rule 12- 8-2The copy assignment operator shall be declared protected or private in an abstract class
Rule 16- 0-7Undefined macro identifiers shall NOt be used in #if or #elif preprocessor directives, except as operands to the defined operator.
Rule 16- 0-7All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if or #ifdef directive to which they are related.