GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libstdc++ Breaking Change

libstdc++: Simplifies basic_filebuf::overflow by removing bump+rewind

libstdc++'s basic_filebuf::overflow is simplified by avoiding pointer advancement and subsequent rewinding, reducing complexity and potential race conditions.

This commit refactors basic_filebuf::overflow in libstdc++ to eliminate the ‘bump and rewind’ mechanism for handling pending output. Previously, when writing pending output failed, the put area’s pointer was advanced and then rewound. This change modifies overflow to not advance the pointer at all. Instead, it increments the size passed to _M_convert_to_external to account for the extra character. This relies on a related change in _M_convert_to_external and ensures the ABI remains compatible by introducing an overloaded _M_convert_to_external function.

In Details

This change affects libstdc++'s stream buffer implementation, specifically basic_filebuf::overflow. The goal is to simplify the error handling path when _M_convert_to_external fails partially. Instead of the old 'bump, write, rewind' sequence, the new implementation avoids bumping pptr() and epptr(). It directly passes the augmented character count to _M_convert_to_external. This relies on _M_convert_to_external being able to handle this without relying on pptr()'s current value. To maintain ABI compatibility, a new overload of _M_convert_to_external is introduced, taking `c…

For Context
basic_filebuf
The base class for file stream buffers in C++'s iostream library, managing input and output operations for files.
overflow
In stream buffers, the overflow function is called when the output buffer is full and needs to write its contents to the underlying output device or stream.
bump and rewind
A pattern where a data pointer is advanced ('bumped') and then reset ('rewound') to its previous position, often used for managing temporary data or correcting errors.
_M_convert_to_external
An internal libstdc++ method responsible for converting character data, potentially involving character set conversions, before writing it to the external file stream.
ABI compatibility
Application Binary Interface compatibility. Ensures that code compiled with an older version of a library can still be linked and run with a newer version, and vice versa, without breaking.
PR118099
A bug report identifier within the GCC bug tracking system, indicating a specific issue that has been reported and is being addressed.
Filed Under: libstdc++iostreamperformanceabi