Hi,

> On 9 Aug 2017, at 17:56, Jonathan Wakely <jwak...@redhat.com> wrote:
> 
> This fixes a couple of problems in __gnu_cxx::stdio_filebuf,
> specifically in the __basic_file::sys_open(FILE*, openmode) function
> it uses when constructed from an existing FILE stream.
> 
> Firstly, r86756 changed __basic_file::sys_open(FILE*, openmode) to put
> the call to sync() before the assignment that sets _M_cfile. This
> means the fflush(_M_cfile) call has a null argument, and flushes all
> open streams. I don't think that was intentional, and we only want to
> flush the FILE we're constructing the streambuf with. (I think this is
> a regression from 3.4.3, which just flushed the one stream).
> 
> Secondly, we zero errno so that we can tell if fflush sets it. We need
> to restore the original value to meet the promise we make at
> https://gcc.gnu.org/onlinedocs/libstdc++/manual/errno.html
> 
> Paolo, does the this->sync() to fflush(__file) change look right?

Yes, I went through the audit trail of libstdc++/81751 and the change looks 
good. Certainly we didn't intentionally want the behavior of fflush(0)!

Thanks!
Paolo

Reply via email to