MISRA C and MISRA C++ define a safe subset of the C and C++ languages. Their rules rule out ambiguous, non-portable or error-prone constructs. Born in the automotive industry, they have become the reference for safety-critical embedded software, from avionics to medical devices. Here is what they contain, which edition to choose, what "MISRA compliant" means, and how to apply them to code that already exists.
MISRA (Motor Industry Software Reliability Association) is a consortium born in the British automotive industry in the 1990s. It has published coding rules for C since 1998, and for C++ since 2008.
C and C++ leave a lot of freedom: undefined behavior, implicit conversions, unspecified order of evaluation, constructs whose result depends on the compiler. MISRA rules close these doors. The code becomes more predictable, more portable from one compiler to another, and easier to review and verify.
Today, MISRA reaches far beyond the automotive industry: aerospace, railway, medical, industrial automation, defense, energy.
| Edition | Target language | In short |
|---|---|---|
| MISRA C:1998 | C90 | First edition, 127 rules. |
| MISRA C:2004 | C90 | 142 rules, grouped by topic. |
| MISRA C:2012 | C90 and C99 | 143 rules and 16 directives, in three categories: mandatory, required, advisory. A 2016 amendment adds security rules. |
| MISRA C:2023 | up to C11 and C17 | Brings together MISRA C:2012 and its amendments. Supports C11 and C17, including multithreading and atomic types. |
| MISRA C:2025 | C90 to C18 | Current edition, more than 200 rules and directives. Guidance for automatically generated code is published separately. |
| MISRA C++:2008 | C++03 | First edition for C++. |
| AUTOSAR C++14 | C++14 | Rules published by the AUTOSAR consortium in 2018 for modern C++, based on MISRA C++:2008. |
| MISRA C++:2023 | C++17 | Current edition, 179 rules and directives. Replaces MISRA C++:2008 and incorporates much of AUTOSAR C++14. |
Take the most recent edition that covers your language version: MISRA C:2025 for C, MISRA C++:2023 for C++17.
It usually keeps the edition chosen at the start: switching editions midway means switching frameworks.
Your customer or your standard may also impose an edition.
Rules and directives. A rule applies to the source code and is checked on the code. A directive also depends on documentation, requirements or process: a tool can only check part of it.
Three categories.
| Category | What it requires |
|---|---|
| Mandatory | Always followed. No deviation allowed. |
| Required | Followed, unless there is a formal, justified and approved deviation. |
| Advisory | Followed as far as possible. A departure needs no formal deviation, but it must be documented. |
Decidable or not. A rule is decidable when a tool can always tell whether the code complies with it. Other rules depend on the values taken at run time. For those, a tool may miss a violation or wrongly report one, and a review is still needed.
File by file, or whole program. Some rules can be checked on a single source file. Others require analyzing the program as a whole.
Every MISRA rule comes with a rationale; none is a matter of personal taste. A few typical topics in C:
An "essential type" model governs implicit conversions, mixing signed and unsigned integers, and loss of precision.
No variable is read before it has been initialized, and no undefined behavior is allowed.
The dynamic memory allocation functions of the standard library are ruled out, and the use of pointers is restricted.
No recursion, goto discouraged, well-formed switch statements.
No ambiguous side effects; the order of evaluation must be explicit.
Macros are restricted, and some standard library functions are ruled out.
MISRA C++ follows the same spirit, with rules specific to C++: conversions, resource management, inheritance, exceptions, templates.
There is no MISRA certification. The development team claims compliance itself, project by project. The framework is set by the MISRA Compliance:2020 document, common to C and C++, which rests on four elements.
Guideline Enforcement Plan: for each rule, how it is checked, by a tool, by a review, or both.
Guideline Re-categorization Plan: the project's own categories. A rule can be made stricter, never more lenient. Only an advisory rule can be disapplied.
Every departure from a required rule is justified, assessed and approved.
Guideline Compliance Summary: for each rule, its status, that is compliant, compliant with deviations, or disapplied.
A project can claim compliance when two conditions are met: all mandatory rules are followed, and all required rules are followed or covered by a formal deviation.
A tool does not make code compliant. It may not cover every rule. It cannot always decide on undecidable rules, and it only checks part of the directives. Compliance is the outcome of a process; static analysis is one link in it.
| Standard | What it asks for |
|---|---|
| ISO 26262-6 (automotive) | Modeling and coding guidelines; MISRA C is cited as an example. |
| IEC 61508-3 (industrial) | Highly recommends a coding standard, at all SIL levels. |
| EN 50716 (railway) | Makes coding standards mandatory at SIL 3 and SIL 4. |
| DO-178C (avionics) | Software code standards defined by the applicant, and verification that they are followed. MISRA is often their basis. |
| IEC 62304 (medical) | For classes B and C, software unit acceptance criteria, for example compliance with a coding standard. |
None of these standards mandates MISRA as such: they ask for a coding standard, and MISRA is the most common choice for C and C++.
TiCS does not check MISRA instead of your tools: it takes in the results of your rule checkers and your C and C++ analyzers, for example PC-Lint or Parasoft C++test. It then tracks them over time:
Languages and tools supported by TiCS →
Guide: static code analysis →
Not as such. Safety standards require a coding standard, and MISRA is the most common choice for C and C++. A customer may also impose it by contract.
For a new project, MISRA C:2025. MISRA C:2023 brings together MISRA C:2012 and its amendments. A project started on an earlier edition usually keeps it until the end.
MISRA C++:2023 targets C++17 and incorporates much of AUTOSAR C++14. For a new C++ project, it is the reference.
CERT C focuses first on security; MISRA C focuses on safety and includes security rules. The two overlap widely, and the same tool can often check both.
No. Check which rules it actually covers. Plan a review for undecidable rules and for directives. Finally, keep the enforcement plan, the deviations and the compliance summary up to date.
From the MISRA website, which sells its documents in PDF format, including MISRA Compliance:2020.
A free TiCS proof of concept, installed and configured by a Precilog consultant, with your own rule checkers.
Static code analysis · TiCS · Languages and integrations · Standards · ISO 26262 · Learn