1. Home
  2. /
  3. Misra-c-cpp
  4. /
  5. MISRA C++: Rule Example (No Dynamic Memory in Safety-Critical Code)

MISRA C++: Rule Example (No Dynamic Memory in Safety-Critical Code) - Misra-c-cpp Typing CST Test

Loading…

MISRA C++: Rule Example (No Dynamic Memory in Safety-Critical Code) — Misra-c-cpp Code

MISRA C++ discourages dynamic allocation in safety-critical systems. Example shows a compliant static allocation approach.

// Non-compliant: dynamic allocation
int* data = new int[10];

// Compliant: use static or stack allocation
int data[10];

Misra-c-cpp Language Guide

MISRA C and MISRA C++ are coding standards developed to facilitate safety, reliability, and maintainability in embedded systems, especially in automotive, aerospace, and critical industries.

Primary Use Cases

  • ▸Automotive embedded software development
  • ▸Safety-critical avionics code
  • ▸Industrial control firmware
  • ▸Medical device software
  • ▸High-integrity and mission-critical systems

Notable Features

  • ▸Rule-based coding guidelines for C/C++
  • ▸Focus on safety, reliability, and maintainability
  • ▸Supports static analysis enforcement
  • ▸Includes both mandatory and advisory rules
  • ▸Covers C language and object-oriented C++ constructs

Origin & Creator

Created by the Motor Industry Software Reliability Association (MISRA) in 1998, initially for the automotive industry; later expanded to C++ and broader safety-critical domains.

Industrial Note

Extensively used in automotive ECUs, aerospace flight control software, industrial PLC firmware, and other high-integrity embedded systems.

More Misra-c-cpp Typing Exercises

MISRA C: Rule Example (Avoid Implicit Conversion)MISRA C: Rule Example (Use of const)MISRA C: Rule Example (No goto)MISRA C: Rule Example (Initialize Variables)MISRA C++: Rule Example (Avoid Multiple Inheritance)MISRA C: Rule Example (Avoid Magic Numbers)MISRA C: Rule Example (Single Point of Exit)MISRA C++: Rule Example (No Exception Handling in Safety-Critical)MISRA C: Rule Example (Boolean Expressions)

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher