On Wed, Apr 1, 2026 at 12:09 PM Jonathan Wakely <[email protected]> wrote:
> Last week in Croydon we approved P3953R3 to rename std::runtime_format
> for C++26. The rationale is that with compile-time std::format, the name
> std::runtime_format doesn't make sense. It's std::dynamic_format now
> instead.
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/chrono_io.h (__formatter_chrono::_S_empty_fs)
> (__formatter_chrono::_M_C_y_Y, __formatter_chrono::_M_D_x)
> (__formatter_chrono::_M_F, __formatter_chrono::_M_subsecs)
> (__formatter_chrono_info::_M_format_to): Use
> _Dynamic_format_string instead of _Runtime_format_string.
> * include/bits/version.def (format): Bump value.
> * include/bits/version.h: Regenerate.
> * include/std/format (_Runtime_format_string): Rename to
> _Dynamic_format_string.
> (runtime_format): Rename to dynamic_format.
> * include/std/print (println): Adjust comment to refer to
> dynamic_format instead of runtime_format.
> * testsuite/std/format/runtime_format.cc: Move to...
> * testsuite/std/format/dynamic_format.cc: ...here.
> ---
>
> Tested x86_64-linux.
>
LGTM.
>
> libstdc++-v3/include/bits/chrono_io.h | 14 ++++++------
> libstdc++-v3/include/bits/version.def | 3 ++-
> libstdc++-v3/include/bits/version.h | 4 ++--
> libstdc++-v3/include/std/format | 18 +++++++--------
> libstdc++-v3/include/std/print | 2 +-
> .../{runtime_format.cc => dynamic_format.cc} | 22 +++++++++----------
> 6 files changed, 32 insertions(+), 31 deletions(-)
> rename libstdc++-v3/testsuite/std/format/{runtime_format.cc =>
> dynamic_format.cc} (51%)
>
> diff --git a/libstdc++-v3/include/bits/chrono_io.h
> b/libstdc++-v3/include/bits/chrono_io.h
> index d152397891f2..f5a0a65a48da 100644
> --- a/libstdc++-v3/include/bits/chrono_io.h
> +++ b/libstdc++-v3/include/bits/chrono_io.h
> @@ -885,9 +885,9 @@ namespace __format
> static constexpr const _CharT* _S_empty_spec = _S_chars + 18;
>
> [[__gnu__::__always_inline__]]
> - static _Runtime_format_string<_CharT>
> + static _Dynamic_format_string<_CharT>
> _S_empty_fs()
> - { return _Runtime_format_string<_CharT>(_S_empty_spec); }
> + { return _Dynamic_format_string<_CharT>(_S_empty_spec); }
>
> static constexpr const _CharT* _S_weekdays[]
> {
> @@ -1321,7 +1321,7 @@ namespace __format
>
> if (__conv != 'y' && __ci >= 100) [[unlikely]]
> {
> - using _FmtStr = _Runtime_format_string<_CharT>;
> + using _FmtStr = _Dynamic_format_string<_CharT>;
> __string_view __fs = _S_minus_empty_spec + !__is_neg;
> __out = std::format_to(std::move(__out), _FmtStr(__fs),
> __conv == 'C' ? __ci : __yi);
> @@ -1360,7 +1360,7 @@ namespace __format
>
> if (__mi >= 100 || __di >= 100) [[unlikely]]
> {
> - using _FmtStr = _Runtime_format_string<_CharT>;
> + using _FmtStr = _Dynamic_format_string<_CharT>;
> __string_view __fs = _GLIBCXX_WIDEN("{:02d}/{:02d}/{:02d}");
> __out = std::format_to(std::move(__out), _FmtStr(__fs),
> __mi, __di, __yi);
> @@ -1416,7 +1416,7 @@ namespace __format
>
> if (__yi >= 10000 || __mi >= 100 || __di >= 100) [[unlikely]]
> {
> - using _FmtStr = _Runtime_format_string<_CharT>;
> + using _FmtStr = _Dynamic_format_string<_CharT>;
> __string_view __fs
> = _GLIBCXX_WIDEN("-{:04d}-{:02d}-{:02d}") + !__is_neg;
> __out = std::format_to(std::move(__out), _FmtStr(__fs),
> @@ -1706,7 +1706,7 @@ namespace __format
> else if (__prec > __max_prec)
> __prec = __max_prec;
>
> - using _FmtStr = _Runtime_format_string<_CharT>;
> + using _FmtStr = _Dynamic_format_string<_CharT>;
> return std::format_to(__out, _FmtStr(_GLIBCXX_WIDEN("{0:0{1}}")),
> __subs, __prec);
> }
> @@ -2110,7 +2110,7 @@ namespace __format
> _Out
> _M_format_to(_Out __out, const chrono::sys_info& __si) const
> {
> - using _FmtStr = _Runtime_format_string<_CharT>;
> + using _FmtStr = _Dynamic_format_string<_CharT>;
> // n.b. only decimal separator is locale dependent for
> specifiers
> // used below, as sys_info uses seconds and minutes duration,
> the
> // output is locale-independent.
> diff --git a/libstdc++-v3/include/bits/version.def
> b/libstdc++-v3/include/bits/version.def
> index 8c9ec854d3b2..434d38c8fbdf 100644
> --- a/libstdc++-v3/include/bits/version.def
> +++ b/libstdc++-v3/include/bits/version.def
> @@ -1321,8 +1321,9 @@ ftms = {
> // 202305 P2757R3 Type checking format args
> // 202306 P2637R3 Member visit
> // 202311 P2918R2 Runtime format strings II
> + // 202603 P3953R3 Rename std::runtime_format
> values = {
> - v = 202311;
> + v = 202603;
> cxxmin = 26;
> hosted = yes;
> };
> diff --git a/libstdc++-v3/include/bits/version.h
> b/libstdc++-v3/include/bits/version.h
> index 836aae02d773..bb2475087f1f 100644
> --- a/libstdc++-v3/include/bits/version.h
> +++ b/libstdc++-v3/include/bits/version.h
> @@ -1473,9 +1473,9 @@
>
> #if !defined(__cpp_lib_format)
> # if (__cplusplus > 202302L) && _GLIBCXX_HOSTED
> -# define __glibcxx_format 202311L
> +# define __glibcxx_format 202603L
> # if defined(__glibcxx_want_all) || defined(__glibcxx_want_format)
> -# define __cpp_lib_format 202311L
> +# define __cpp_lib_format 202603L
> # endif
> # elif (__cplusplus >= 202002L) && _GLIBCXX_HOSTED
> # define __glibcxx_format 202304L
> diff --git a/libstdc++-v3/include/std/format
> b/libstdc++-v3/include/std/format
> index 555781bbd274..2bcd06822b75 100644
> --- a/libstdc++-v3/include/std/format
> +++ b/libstdc++-v3/include/std/format
> @@ -125,14 +125,14 @@ namespace __format
> using __format_context = basic_format_context<_Sink_iter<_CharT>,
> _CharT>;
>
> template<typename _CharT>
> - struct _Runtime_format_string
> + struct _Dynamic_format_string
> {
> [[__gnu__::__always_inline__]]
> - _Runtime_format_string(basic_string_view<_CharT> __s) noexcept
> + _Dynamic_format_string(basic_string_view<_CharT> __s) noexcept
> : _M_str(__s) { }
>
> - _Runtime_format_string(const _Runtime_format_string&) = delete;
> - void operator=(const _Runtime_format_string&) = delete;
> + _Dynamic_format_string(const _Dynamic_format_string&) = delete;
> + void operator=(const _Dynamic_format_string&) = delete;
>
> private:
> basic_string_view<_CharT> _M_str;
> @@ -173,7 +173,7 @@ namespace __format
> basic_format_string(const _Tp& __s);
>
> [[__gnu__::__always_inline__]]
> - basic_format_string(__format::_Runtime_format_string<_CharT> __s)
> noexcept
> + basic_format_string(__format::_Dynamic_format_string<_CharT> __s)
> noexcept
> : _M_str(__s._M_str)
> { }
>
> @@ -197,14 +197,14 @@ namespace __format
>
> #if __cpp_lib_format >= 202311L // >= C++26
> [[__gnu__::__always_inline__]]
> - inline __format::_Runtime_format_string<char>
> - runtime_format(string_view __fmt) noexcept
> + inline __format::_Dynamic_format_string<char>
> + dynamic_format(string_view __fmt) noexcept
> { return __fmt; }
>
> #ifdef _GLIBCXX_USE_WCHAR_T
> [[__gnu__::__always_inline__]]
> - inline __format::_Runtime_format_string<wchar_t>
> - runtime_format(wstring_view __fmt) noexcept
> + inline __format::_Dynamic_format_string<wchar_t>
> + dynamic_format(wstring_view __fmt) noexcept
> { return __fmt; }
> #endif
> #endif // C++26
> diff --git a/libstdc++-v3/include/std/print
> b/libstdc++-v3/include/std/print
> index 6ffd9a4b1b3f..1b9e810419f0 100644
> --- a/libstdc++-v3/include/std/print
> +++ b/libstdc++-v3/include/std/print
> @@ -352,7 +352,7 @@ namespace __format
> (enable_nonlocking_formatter_optimization<remove_cvref_t<_Args>>
> && ...);
>
> // The standard wants us to call
> - // print(stream, runtime_format(string(fmt.get()) + '\n'), args...)
> + // print(stream, dynamic_format(string(fmt.get()) + '\n'), args...)
> // here, but we can avoid that string concatenation in most cases,
> // and we know what that would call, so we can call that directly.
>
> diff --git a/libstdc++-v3/testsuite/std/format/runtime_format.cc
> b/libstdc++-v3/testsuite/std/format/dynamic_format.cc
> similarity index 51%
> rename from libstdc++-v3/testsuite/std/format/runtime_format.cc
> rename to libstdc++-v3/testsuite/std/format/dynamic_format.cc
> index f2bfa5b434d2..fde2555ccb2f 100644
> --- a/libstdc++-v3/testsuite/std/format/runtime_format.cc
> +++ b/libstdc++-v3/testsuite/std/format/dynamic_format.cc
> @@ -7,7 +7,7 @@ void
> test_char()
> {
> std::string fmt = "{}";
> - auto s = std::format(std::runtime_format(fmt), 123);
> + auto s = std::format(std::dynamic_format(fmt), 123);
> VERIFY( s == "123" );
> }
>
> @@ -15,30 +15,30 @@ void
> test_wchar()
> {
> std::wstring fmt = L"{:#o}";
> - auto s = std::format(std::runtime_format(fmt), 456);
> + auto s = std::format(std::dynamic_format(fmt), 456);
> VERIFY( s == L"0710" );
> }
>
> void
> test_internal_api()
> {
> - // Using _Runtime_format_string directly works even in C++20 mode.
> + // Using _Dynamic_format_string directly works even in C++20 mode.
> // This can be used internally by libstdc++.
> std::string fmt = "{:#x}";
> - auto s = std::format(std::__format::_Runtime_format_string<char>(fmt),
> 789);
> + auto s = std::format(std::__format::_Dynamic_format_string<char>(fmt),
> 789);
> VERIFY( s == "0x315" );
> }
>
> -static_assert( noexcept(std::format_string<>(std::runtime_format(""))) );
> -static_assert( noexcept(std::wformat_string<>(std::runtime_format(L"")))
> );
> -static_assert( noexcept(std::format_string<int>(std::runtime_format("")))
> );
> -static_assert(
> noexcept(std::wformat_string<char>(std::runtime_format(L""))) );
> -// A format string can be constructed from the result of
> std::runtime_format
> +static_assert( noexcept(std::format_string<>(std::dynamic_format(""))) );
> +static_assert( noexcept(std::wformat_string<>(std::dynamic_format(L"")))
> );
> +static_assert( noexcept(std::format_string<int>(std::dynamic_format("")))
> );
> +static_assert(
> noexcept(std::wformat_string<char>(std::dynamic_format(L""))) );
> +// A format string can be constructed from the result of
> std::dynamic_format
> // using copy elision, but cannot be constructed from an xvalue.
> static_assert( !std::is_constructible_v<std::format_string<>,
> -
> decltype(std::runtime_format(""))&&> );
> +
> decltype(std::dynamic_format(""))&&> );
> static_assert( !std::is_constructible_v<std::wformat_string<>,
> -
> decltype(std::runtime_format(L""))&&> );
> +
> decltype(std::dynamic_format(L""))&&> );
>
> int main()
> {
> --
> 2.53.0
>
>