C++ Runtime -
vtable for B: [0] offset_to_top = 0 [1] typeinfo pointer -> typeinfo for B [2] A::foo() thunk (if overriding) vtable for A: [0] offset_to_top = 0 [1] typeinfo pointer -> typeinfo for A
main → foo() → bar() → throw MyException(); → __cxa_throw (sets unwind info, calls _Unwind_RaiseException) → _Unwind_RaiseException → _Unwind_RaiseException_Phase1 (walks .eh_frame) → _Unwind_RaiseException_Phase2 (calls personality, destructors) → __gxx_personality_v0 (calls destructors of locals in bar, foo) → land on catch in main On Linux: readelf -S a.out (look for .init_array , .eh_frame , .gcc_except_table ) On Windows: dumpbin /HEADERS myapp.exe (look for .pdata for x64 exception tables) This report is based on the Itanium C++ ABI (version 1.2), Microsoft C++ ABI (x64), and publicly available documentation for GCC 13, Clang 17, and MSVC 2022. c++ runtime
static char instance_memory[sizeof(Logger)]; static uint8_t guard = 0; // 0 = uninitialized, 1 = initializing, 2 = done if (guard == 2) goto done; if (__cxa_guard_acquire(&guard)) new (instance_memory) Logger(); __cxa_guard_release(&guard); __cxa_atexit(destroyer, instance_memory, __dso_handle); vtable for B: [0] offset_to_top = 0 [1]
static Logger& getLogger() static Logger instance; // thread‑safe initialization return instance; Unlike C, which has a relatively minimal runtime,
Report ID: CPP-RT-2024-01 Date: April 14, 2026 Author: Systems Software Research Division Subject: Structure, Execution Flow, and Overhead of the C++ Runtime Environment 1. Executive Summary The C++ runtime is the set of software components that support the execution of a compiled C++ program beyond the raw machine code generated by the compiler. Unlike C, which has a relatively minimal runtime, C++ requires substantial behind‑the‑scenes machinery to implement core language features: dynamic initialization of globals, exception handling, run‑time type information (RTTI), new / delete operators, and stack unwinding. This report dissects the C++ runtime into its constituent parts, traces the execution flow from _start to main and beyond, analyzes the cost of each runtime feature, and examines implementation variations across major compilers (GCC/Clang, MSVC) and operating systems. 2. Components of the C++ Runtime The C++ runtime is not monolithic. It consists of several logical layers:
done: return instance_memory;
When dynamic_cast<B*>(a_ptr) is performed, the runtime reads the vtable of the object to obtain the type_info of the most derived type and checks if it derives from B .

