MONDAY, AUGUST 24, 2026
libstdc++
libstdc++: Fix output stream spanbuf openmode
Ensures `basic_ospanstream` correctly opens its internal span buffer for output.
A copy-paste error in the basic_ospanstream constructor for libstdc++ caused it to incorrectly initialize its basic_spanbuf. This commit corrects the openmode parameter, ensuring the span buffer is properly opened for output operations, and includes a new test case to verify the fix.
In Details
The constructor for std::basic_ospanstream in libstdc++ was erroneously passing an incorrect openmode to its constituent basic_spanbuf. This commit corrects the constructor to pass the appropriate std::ios_base::openmode flags required for output operations on the basic_spanbuf, fixing PR127006.
For Context
- basic_ospanstream
- A C++ standard library stream class that writes to a contiguous sequence of elements in memory (a span).
- spanbuf
- The stream buffer associated with
basic_spanstreamclasses, handling the actual input/output operations on a memory span. - openmode
- A set of flags (e.g.,
ios_base::in,ios_base::out,ios_base::trunc) used to specify how a file or stream buffer should be opened.