https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114256
Bug ID: 114256
Summary: std::filebuf::setbuf does nothing if the file is open
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
This was changed by g:dfad48c6e89fcfed for PR 12875. This was also the subject
of PR 9423, but Benjamin argued there that opening the file counts as an I/O
operation. That contradicts C and POSIX which say this for the (very similar)
setvbuf:
"The setvbuf function may be used only after the stream pointed to by stream
has been
associated with an open file and before any other operation (other than an
unsuccessful call to setvbuf) is performed on the stream."
Obviously in C you can't do anything with a FILE* before you've opened it, and
you can call setbuf on a default-constructed filebuf before opening a file. But
I don't see why the behaviour should differ here.