Kokeb Labs code is ISO C++20 (ADR-0010), and MISRA C++:2023, our reference coding standard, is written for C++17.
This profile closes the gap. It sorts every C++17 and C++20 feature we have a view on into Use, Use with
rules and Forbid, and states the rules as numbered guidelines, KB-CPP20-001 to KB-CPP20-058 (the
C++20 profile rules), each with its category, scope, the MISRA C++:2023 guidelines it extends
or relates to (by number only) and the tool or review step that enforces it.
The profile is also what deviation MD-CPP-001 covers
(compliance/misra-cpp-2023-deviations.yml):
the features marked Use and Use with rules, each under its guidelines, and nothing else. A feature marked
Forbid, anything C++20 deprecates, and every feature of C++23 or later is a violation of Rule 4.1.1 with no
deviation, even in a build whose dialect accepts it (ESP-IDF compiles as gnu++23 or gnu++26 by default). A
feature moves into the covered set only by a change to this page, rules/cpp20.yml and MD-CPP-001 in one pull
request.
Category follows MISRA's model. Mandatory: breaking it is undefined behaviour or an unrecoverable defect,
and it is never deviated. Required: followed unless a deviation record exists. Advisory: followed unless a
reviewer accepts a stated reason. Mandatory and required guidelines are must rules, advisory ones should
rules. A guideline is never classified below the MISRA guideline it extends. The set has 4 mandatory, 36
required and 18 advisory guidelines.
Scope: D drivers and the driver template, L libraries, H HALs, BSP binds and firmware. Test code in every
repository follows the language-level guidelines (KB-CPP20-001 to 004), not the library-subset ones.
MISRA C++:2023 lists the guidelines a rule extends or relates to. The standard's text is not reproduced
here; the compliance matrix holds our own one-line summary of each.
Enforced by names the compiler flag, clang-tidy check, handbook source check (cpp20-profile/...,
checks/source_checks.py), the strict-dialect build, a query of the planned Kokeb CodeQL pack, or the review
step. Each rule's page entry lists the exact checks.
MD-CPP-001's mitigation applies every guideline of the edition to the C++20 constructs we use, by these analogies.
The commercial checker's C++20 findings are triaged against them.
C++20 construct
Treated as
Guidelines
A concept
A template: the rules on templates apply to its instantiations
17.8.1 and the template rules
The parameters of a requires-expression
Not function parameters: the unused-parameter rule does not apply to them
0.2.2
A designated initialiser
An initialisation: the conversion rule applies to each designator
7.0.6
Indexing a std::span
An array access; a span is a reference-like object for the lifetime rules
8.7.1; 6.8.1 to 6.8.4
A defaulted operator==
Covered by MD-CPP-002 and KB-CPP20-033
16.6.1
A lambda in a template argument
A function object
8.1.1, 8.1.2
std::bit_cast
The permitted alternative to the casts these rules forbid, never applied to pointers
8.2.5, 8.2.6
A constinit object
Still a mutable static, inside MD-CPP-005's scope
6.7.2
A discarded if constexpr branch that no instantiation keeps
Compiler, in every target a repository builds: -std=c++20 with CMAKE_CXX_EXTENSIONS OFF,
-pedantic-errors, -Wdeprecated -Wdeprecated-enum-enum-conversion -Wdeprecated-enum-float-conversion,
-Wimplicit-fallthrough, on top of KB-CPP-104's warnings and -Werror. Host tests and fuzz targets add the
standard library's assertions (-D_GLIBCXX_ASSERTIONS, libc++ hardening) and the sanitizers.
Strict-dialect build: every public header compiles alone at -std=c++20 -pedantic-errors with host GCC and
Clang (host tests), Arm GCC (cross-build), and the ESP-IDF toolchain through a header self-check compiled at
-std=c++20 inside the ESP-IDF build, which also asserts that the flag took effect.
clang-tidy (config/.clang-tidy): bugprone-dangling-handle also watches std::span; the checks that
suggest std::print and std::format are off.
Source checks (checks/source_checks.py scan): cpp20-profile/forbidden-features,
cpp20-profile/cmake-extensions, cpp20-profile/nodiscard-error, cpp20-profile/inline-requires and
cpp20-profile/kconfig-leaf, each proved by the script's self-test with a seeded violation.
CodeQL (planned): the guidelines marked CodeQL get a query in the Kokeb pack; until then they are review
steps. In priority order: 021, 022, 025, 058, 042, 020, 033, 006, 012, 044 and 045, then the rest.
The driver template carries the patterns this profile asks for, with tests: exact port concepts
(detail::Exactly<T>), named optional-hook concepts, typed register fields (detail::Field), strong unit types
for public conversions, fixed-extent spans on the bus helpers, consteval checked configurations, and round-trip
static_asserts for encoders, CRC vectors and presets. None of them changes the generated code of the run-time
path. Its docs/template.md describes each one.
Every feature in the Use and Use with rules sets is available from GCC 11 and Clang 17; the pinned compilers
(host GCC 14 and Clang 18, Arm GCC 14, ESP-IDF's GCC) all exceed that. Features of note: