Fix a flush issue on libstdc++

This commit is contained in:
Victor Zverovich
2025-03-30 09:55:13 -07:00
parent 2f58430573
commit 5199e0f885
2 changed files with 32 additions and 3 deletions

View File

@@ -1526,9 +1526,8 @@ template <typename F> class glibc_file : public file_base<F> {
}
void init_buffer() {
if (this->file_->_IO_write_ptr) return;
if (this->file_->_IO_write_ptr < this->file_->_IO_write_end) return;
// Force buffer initialization by placing and removing a char in a buffer.
assume(this->file_->_IO_write_ptr >= this->file_->_IO_write_end);
putc_unlocked(0, this->file_);
--this->file_->_IO_write_ptr;
}