Skip to content

Commit f523559

Browse files
committed
New issue from Jiang An: "What should std::format_to etc. behave when the output is overlong?"
1 parent 69ff630 commit f523559

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

xml/issue4263.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4263" status="New">
5+
<title>What should `std::format_to` etc. behave when the output is overlong?</title>
6+
<section><sref ref="[format]"/></section>
7+
<submitter>Jiang An</submitter>
8+
<date>14 May 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
It seems permitted to write overly long contents via an (C++20) output iterator with
14+
`std::format_to(_n)`, where the length isn't representable in `size_t` or `ptrdiff_t`,
15+
especially when the implementation provides integer-class types. However, currently
16+
some implementation can't properly handle content whose length is greater than
17+
`PTRDIFF_MAX`. Presumably we don't want UB in such cases. Should we explicitly allow
18+
throwing exception and/or silent truncation?
19+
<p/>
20+
Additionally, given that the return type of `std::formatted_size` is `std::size_t`,
21+
even if the implementation supports formatted contents whose lengths are greater than
22+
`SIZE_MAX`, the length can't be correctly returned. Perhaps we need to either precisely
23+
specify the return value as modulo arithmetic seems undesired, or specify that an
24+
exception is thrown.
25+
</p>
26+
</discussion>
27+
28+
<resolution>
29+
</resolution>
30+
31+
</issue>

0 commit comments

Comments
 (0)