<ostream>: When is setting badbit a bad thing to do?
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.2k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
We appear to be inconsistent about our behavior after constructing a sentry. Usually, we just test it:
But sometimes, we set badbit. I believe I've found Standardese justifying two of these occurrences, but there are several more.
- Required by https://eel.is/c++draft/ostream.unformatted#3
https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/ostream#L505-L511 - Required by https://eel.is/c++draft/ostream.unformatted#5.2
https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/ostream#L523-L530
Here are the occurrences that I can't find Standardese for - is this a bug? The difference appears to be that the badbit setters above are unformatted output functions, while the occurrences below are formatted output functions.
-
https://eel.is/c++draft/ostream.formatted#ostream.inserters.character-4
https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/ostream#L649-L658 -
https://eel.is/c++draft/ostream.formatted#ostream.inserters.character-4 (again)
https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/ostream#L729-L742 -
https://eel.is/c++draft/ostream.formatted#ostream.inserters.character-4 (yet again)
https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/ostream#L812-L823 -
https://eel.is/c++draft/quoted.manip#2
https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/iomanip#L261-L292 -
https://eel.is/c++draft/string.view.io#1
https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/xstring#L425-L443
All of these lead to https://eel.is/c++draft/ostream.formatted.reqmts#1 .
(Standardese citations as of WG21-N4835.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the listed badbit handling in stl/inc/ostream, stl/inc/iomanip, and stl/inc/xstring, then compare each occurrence with the cited WG21-N4835 clauses. Determine whether the formatted-output cases conform to the referenced Standardese and identify the correct behavior for each location. Done means reaching a justified conformance decision for all five cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100