[PATCH v3 2/2] libstdc++: Use __chrono_write via _S_empty_fs for chrono ostream insertion
Anlai Lu
agicy@qq.com
Thu Jul 23 03:30:31 GMT 2026
> On Jul 1, 2026, at 21:00, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On Wed, 1 Jul 2026 at 13:59, Richard Earnshaw (foss)
> <Richard.Earnshaw@arm.com <mailto:Richard.Earnshaw@arm.com>> wrote:
>>
>> On 01/07/2026 13:33, Tomasz Kaminski wrote:
>>>
>>>
>>> On Wed, Jul 1, 2026 at 2:15 PM Anlai Lu <agicy@qq.com <mailto:agicy@qq.com>> wrote:
>>>
>>> Add __detail::__chrono_write which formats a chrono object into a
>>> stack buffer via std::format_to_n with _S_empty_fs(), then writes
>>> through __ostream_insert. A non-type template parameter _BufSize
>>> (default 128) allows per-type buffer tuning. Each _BufSize is the
>>> smallest power of two that accommodates the longest possible formatted
>>> output for that type, including error cases. All chrono operator<<
>>> overloads that previously used std::format, std::vformat, or
>>> basic_stringstream now use this helper.
>>>
>>> libstdc++-v3/ChangeLog:
>>>
>>> * include/bits/chrono_io.h (__formatter_chrono::_S_empty_fs):
>>> Make public.
>>> (__detail::__chrono_write): New function template.
>>> (operator<<): Use __chrono_write consistently for all chrono
>>> types.
>>>
>>> Signed-off-by: Anlai Lu <agicy@qq.com <mailto:agicy@qq.com>>
>>> ---
>>> libstdc++-v3/include/bits/chrono_io.h | 244 ++++++--------------------
>>> 1 file changed, 52 insertions(+), 192 deletions(-)
>>>
>>> LGTM. Thank you for working on this.
>>>
>>
>> I think this is causing:
>>
>> /home/rearnsha/gnusrc/gcc-cross/misc-fixes/libstdc++-v3/src/c++20/tzdb.cc: In st
>> atic member function ‘static const std::chrono::tzdb& std::chrono::tzdb_list::_N
>> ode::_S_replace_head(std::shared_ptr<std::chrono::tzdb_list::_Node>, std::shared
>> _ptr<std::chrono::tzdb_list::_Node>)’:
>> /home/rearnsha/gnusrc/gcc-cross/misc-fixes/libstdc++-v3/src/c++20/tzdb.cc:1617:22: error: ‘struct std::chrono::tzdb_list::_Node::NumLeapSeconds’ has no member named ‘set_locked’
>> 1617 | num_leap_seconds.set_locked(new_head_ptr->db.leap_seconds.size(), lock);
>> | ^~~~~~~~~~
>> make[9]: *** [Makefile:575: tzdb.lo] Error 1
>>
>> when building an arm-eabi cross with newlib.
>
> That's a different patch (this one isn't committed yet) but I'll take
> care of it.
Right, that build issue turned out to be unrelated. Just checking back on this
series - patch 1/2 went in with the dg-require cleaned up, and patch 2/2
has Tomasz's review. Are there any remaining concerns?
Thanks,
Anlai
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20260723/3afcd1cc/attachment.htm>
More information about the Libstdc++
mailing list