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.
4039. §[ostream.formatted.print]: Inappropriate usage ofbadbit
in definition of vprint_unicode
/vprint_nonunicode
Section: 31.7.6.3.5 [ostream.formatted.print] Status: New Submitter: Jan Kokemüller Opened: 2024-01-13 Last modified: 2024-01-20
Priority: Not Prioritized
View all other issues in [ostream.formatted.print].
View all issues with New status.
Discussion:
In section 31.7.6.3.5 [ostream.formatted.print], bullet 3.2 there is a mention of badbit
:
any exception thrown by the call to
vformat
is propagated without regard to the value ofos.exceptions()
and without turning onios_base::badbit
in the error state ofos
.
Now the affected functions vprint_unicode
and vprint_nonunicode
are specified to behave as formatted output functions (31.7.6.3.1 [ostream.formatted.reqmts]), which distinguishes two phases:
Output generation, which would call setstate(ios_base::failbit)
in case of a failure (which may throw an exception)
The actual output itself, which would call setstate(ios_base::badbit)
in case of an exception
The vformat
call is obviously part of the first phase (since it generates the output sequence and not yet the actual output), and any failure here (such as an exception) would under regular formatted output function rules set ios_base::failbit
and not ios_base::badbit
(the latter would indicate a loss of the actual output sequence integrity and is therefore set by the second phase in case of an exception).
ios_base::badbit
in (3.2) doesn't really make sense, it could only meaningfully refer to ios_base::failbit
instead.
Proposed resolution:
This wording is relative to N4971.
Modify 31.7.6.3.5 [ostream.formatted.print] as indicated:
void vprint_unicode(ostream& os, string_view fmt, format_args args); void vprint_nonunicode(ostream& os, string_view fmt, format_args args);-3- Effects: Behaves as a formatted output function (31.7.6.3.1 [ostream.formatted.reqmts]) of
os
, except that:
(3.1) — failure to generate output is reported as specified below, and
(3.2) — any exception thrown by the call to
vformat
is propagated without regard to the value ofos.exceptions()
and without turning onios_base:: failbit badbit
in the error state ofos
.[…]
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