GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libstdc++

Make libstdc++ dynamic format string checking work with Clang.

Refactored C++ `<format>` dynamic spec checking to avoid out-of-line function template instantiation issues with Clang.

A bug in Clang prevents it from compiling format string checking functions that are defined out-of-line as templates. This patch refactors basic_format_parse_context::check_dynamic_spec and related functions in libstdc++, making their definitions inline within the class body. It also simplifies argument handling by using span<_Arg_t> instead of template parameter packs, resolving the Clang compilation issue and slightly simplifying the code.

In Details

This commit addresses a Clang compilation issue ([llvm/llvm-project#73232](https://github.com/llvm/llvm-project/issues/73232)) where out-of-line function templates instantiated during constant evaluation in libstdc++'s <format> library fail to compile. The affected function is basic_format_parse_context::check_dynamic_spec. The solution involves moving the definitions of check_dynamic_spec and associated helpers (like __check_dynamic_spec) inline within the class. Additionally, the interface of __check_dynamic_spec is changed from accepting a template parameter pack of argument ty…

For Context
libstdc++
The C++ Standard Library implementation used by GCC. It provides functionalities defined by the C++ standard, such as containers, algorithms, and I/O streams.
<format>
A C++ header introduced in C++20 providing functionality for formatting output, similar to Python's f-strings or C#'s string.Format.
dynamic format string checking
A feature that verifies at runtime whether the arguments provided to a format string match the expected types and number of placeholders in the format string itself.
out-of-line function template
A function template whose definition is not immediately visible where it's instantiated, requiring a separate compilation unit or linkage step to resolve.
constant evaluation
The process by which a compiler evaluates expressions at compile time, rather than at runtime. This is often done for constexpr functions and variables in C++.
span
A C++20 language feature providing a non-owning view over a contiguous sequence of objects. It simplifies passing views of arrays or parts of arrays.
Filed Under: libstdc++formatclangbugfix