https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117085
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Last reconfirmed| |2024-10-11 Status|UNCONFIRMED |ASSIGNED Target Milestone|--- |13.4 Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- Thanks for identifying exactly where the bug is! I'll test this patch: --- a/libstdc++-v3/include/bits/chrono_io.h +++ b/libstdc++-v3/include/bits/chrono_io.h @@ -912,17 +912,20 @@ namespace __format // %c Locale's date and time representation. // %Ec Locale's alternate date and time representation. + basic_string<_CharT> __fmt; auto __t = _S_floor_seconds(__tt); locale __loc = _M_locale(__ctx); const auto& __tp = use_facet<__timepunct<_CharT>>(__loc); const _CharT* __formats[2]; __tp._M_date_time_formats(__formats); const _CharT* __rep = __formats[__mod]; - if (!*__rep) [[unlikely]] - __rep = _GLIBCXX_WIDEN("%a %b %e %T %Y"); - basic_string<_CharT> __fmt(_S_empty_spec); - __fmt.insert(1u, 1u, _S_colon); - __fmt.insert(2u, __rep); + if (const _CharT* __rep = __formats[__mod]; *__rep) [[likely]] + { + __fmt = _GLIBCXX_WIDEN("{:L}"); + __fmt.insert(3u, __rep); + } + else + __fmt = _GLIBCXX_WIDEN("{:L%a %b %e %T %Y}"); return std::vformat_to(std::move(__out), __loc, __fmt, std::make_format_args<_FormatContext>(__t)); }