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.
4078. What if arguments alias the output buffer instd::format_to
?
Section: 28.5.5 [format.functions] Status: New Submitter: Jan Schultke Opened: 2024-04-24 Last modified: 2025-02-07
Priority: 4
View all other issues in [format.functions].
View all issues with New status.
Discussion:
int main() { int x = 12345; // note: this is "awoo" followed by 28 zeros (9.5.3 [dcl.init.string] p3) char buffer[32] = "awoo"; std::format_to(buffer, "{}{}", x, buffer); std::println("{}", buffer); }
The output of this code is unspecified to be either "1234512345"
or "12345awoo"
, where GCC currently outputs the former. Formatting occurs through function calls (see 28.5.6.4 [format.formatter.spec] p1) and those cannot be unsequenced, however, it's also nowhere stated in what order the arguments get formatted and how the output iterator is advanced between calls to the formatters.
f.format(u, fc)
).
[2025-02-07; Reflector poll]
Set priority to 4 after reflector poll.
We should prohibit aliasing, so this is undefined.
Proposed resolution:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4