microsoft / microsoft/STL

<ostream>: When is setting badbit a bad thing to do?

Open
#283 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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:

https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/ostream#L266-L270

But sometimes, we set badbit. I believe I've found Standardese justifying two of these occurrences, but there are several more.

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.

  1. https://eel.is/c++draft/ostream.formatted#ostream.inserters.character-4
    https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/ostream#L649-L658

  2. https://eel.is/c++draft/ostream.formatted#ostream.inserters.character-4 (again)
    https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/ostream#L729-L742

  3. 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

  4. https://eel.is/c++draft/quoted.manip#2
    https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/iomanip#L261-L292

  5. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.