GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
libstdc++

libstdc++ safely handles unrecognized format_arg types

Format library now uses a fallback mechanism for unrecognized argument types, preventing UB and improving compatibility.

The C++ format library in libstdc++ now gracefully handles unrecognized _Arg_t values in basic_format_arg. Instead of calling __builtin_unreachable which can lead to undefined behavior, a new _M_handle_unrecognized method is invoked. This ensures backward compatibility when newer library versions are used with older binaries, preventing crashes and providing better runtime robustness.

In Details

libstdc++ <format> ABI evolution: basic_format_arg specializations for format_context and wformat_context now export _M_handle_unrecognized to cope with future _Arg_t extensions. This avoids UB from unrecognized values when a newer libstdc++.so is used with an older executable. This mechanism becomes crucial for visit_format_arg on newer types. The __type parameter is removed from _M_visit helpers, relying on _M_type for consistency.

For Context
libstdc++
The GNU Standard C++ Library, a fundamental component of GCC that provides the C++ standard library implementation.
basic_format_arg
An internal representation within the C++ <format> library that holds a formatted argument, capable of deferring its actual type.
_Arg_t
An enumeration type used internally by the C++ <format> library to distinguish between different kinds of arguments that can be formatted.
UB
Undefined Behavior. Situations in code where the C++ standard does not specify the outcome, leading to unpredictable program behavior, crashes, or security vulnerabilities.
ABI
Application Binary Interface. Defines how compiled code is linked and executed, including function calling conventions, data layout, and system call interfaces.
Filed Under: libstdc++formatabicompatibility