WIP: [wip,nomerge,rfc] build: Require C++23 compiler

bitcoin/bitcoin: PR #36033

1 major finding · 1 minor finding · 3 suggestions

Earlier concerns neither republished nor resolved: 1 major finding. See the Run archive for their assessments.

Findings

Link

[major] · GCC 12 remains selected after the code starts requiring GCC 13

Source inspection indicates that the unchanged GCC 12 CI job cannot compile the new static_assert(false), while doc/dependencies.md still advertises GCC 12.1; no GCC 12 build was run.

Location: src/logging/timer.h:76 (head).

Details and suggested fix

GCC 12 rejects this non-dependent assertion when parsing Timer, even when a supported TimeType would discard the branch. Accepting it requires GCC 13's implementation of CWG2518/P2593. Since validation.cpp includes this header, disabling the optional kernel library does not avoid the problem. The active previous-releases job still passes CC=gcc-12 CXX=g++-12 through depends into the main build. Its dev-mode preset also enables the kernel library, whose new std::views::zip requires libstdc++ 13. The job therefore cannot reach its extended and previous-release tests.

Raise the documented GCC minimum to 13 and update that job's selected compiler, preserving its Python 3.10 coverage separately if necessary. Name the concrete minimum in release-notes-36033.md rather than relying only on the C++23 language-mode requirement.


Link

[minor] · C++23 bypasses the Cap'n Proto/Clang compatibility diagnostic

The C++23 bump suppresses the compatibility diagnostic for an already unsupported Clang/Cap'n Proto setup, leaving header errors instead of upgrade guidance; this consequence is inferred, not observed.

Location: CMakeLists.txt:84 (head).

Details and suggested fix

With internal IPC enabled, the non-Windows default, libmultiprocess inherits CMAKE_CXX_STANDARD=23. Its compatibility condition requires CMAKE_CXX_STANDARD EQUAL 20, so Clang builds using Cap'n Proto 0.9.2 or patched 0.10.x releases now bypass the error; those versions also pass the separate CVE check. Clang's P2468R2 behavior still applies in C++23, so changing the language mode does not resolve the header incompatibility. Previously, configuration explained how to upgrade to 1.0, use GCC, or disable IPC. Change the upstream condition to CMAKE_CXX_STANDARD GREATER_EQUAL 20, update its message, and synchronize the subtree with this bump.


Optional improvements

Link

[suggestion] · The Expected alias drops project-enforced wrong-alternative checks

Replacing util::Expected with std::expected removes its project-enforced fail-fast checks; no misusing current caller was found, and equivalent vendor-library hardening has not been verified.

Location: src/util/expected.h:14 (head).

Details and suggested fix

The former error() used the always-on Assert, while operator* and operator-> called throwing value() from noexcept functions and therefore terminated on the wrong alternative. The alias changes these accesses to standard-library precondition violations. Leaving NDEBUG unset does not portably enforce those preconditions, and the explicit in-tree library-hardening definitions are debug/fuzz-only. The project's Clang LIFETIMEBOUND annotations likewise become library-dependent. Keep the active-state Assert checks in a thin wrapper around the standard implementation to retain deterministic failure on a broken result-state invariant.


Link

[suggestion] · The early toolchain probe omits the newly required C++23 facilities

The alias-CTAD probe can accept a compiler/library pair missing newly required C++23 facilities, delaying failure until compilation instead of providing early toolchain guidance; no affected build was run.

Location: CMakeLists.txt:84 (head).

Details and suggested fix

CheckCXXFeatures still tests only alias-template CTAD, and CMAKE_CXX_STANDARD_REQUIRED does not establish availability of individual language or library features. Add small check_cxx_source_compiles probes for the discarded-branch static_assert(false), std::expected, std::byteswap, and std::views::zip, reporting missing capabilities through the existing toolchain diagnostic. Gate the zip probe on actually building the kernel library so other configurations are not rejected. This also checks the selected standard library, which can be older than the compiler, and makes its required capabilities explicit.


Link

[suggestion] · Kernel import coverage does not depend on the supplied filename

The pre-existing nonempty-path test can pass if the rewritten conversion drops or corrupts its path, because it reuses an indexed chain and checks only ImportBlocks()'s boolean result.

Location: src/kernel/bitcoinkernel.cpp:1373 (head).

Details and suggested fix

chainman_reindex_chainstate_test runs after the mainnet validation and reindex helpers have established a height-1 chain in the same directory. It wipes only chainstate, leaving the block index available for reconstruction. In node::ImportBlocks, an unusable filename only produces a warning, and the C API returns zero unless an exception escapes. Consequently, skipping or truncating the path in the new std::views::zip conversion need not fail this test. Add an import test using a fresh destination without an indexed copy of the imported blocks, and assert the resulting tip height or hash so the result depends on successfully reading the supplied file.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

Language-baseline changes were historically gated by practical self-compilation support, not just the availability of a language-mode flag. The C++20 transition targeted Bitcoin Core 27.0 with GCC 10 and Clang 13, after checking their availability on supported operating systems. Its stated benefits were stronger compile-time enforcement and clearer code.

This supplies the historical tradeoff behind the previous baseline: obtain safety and maintainability improvements without making source builds unnecessarily inaccessible. The discussion explicitly distinguished using newer compilers for release binaries from requiring users on older systems to install them. It also clarified that requiring a newer compiler did not itself mean dropping an operating system as a build platform.

Source 1 · Source 2 · Source 3 · Source 4 · Source 5