This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
std::format_to
etc. behave when the output is overlong?Section: 28.5 [format] Status: New Submitter: Jiang An Opened: 2025-05-14 Last modified: 2025-05-18
Priority: Not Prioritized
View other active issues in [format].
View all other issues in [format].
View all issues with New status.
Discussion:
It seems permitted to write overly long contents via an (C++20) output iterator with
std::format_to(_n)
, where the length isn't representable in size_t
or ptrdiff_t
,
especially when the implementation provides integer-class types. However, currently
some implementation can't properly handle content whose length is greater than
PTRDIFF_MAX
. Presumably we don't want UB in such cases. Should we explicitly allow
throwing exception and/or silent truncation?
std::formatted_size
is std::size_t
,
even if the implementation supports formatted contents whose lengths are greater than
SIZE_MAX
, the length can't be correctly returned. Perhaps we need to either precisely
specify the return value as modulo arithmetic seems undesired, or specify that an
exception is thrown.
Proposed resolution: