This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/45708] fstream reads after writes, or vice versa, don't work


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45708

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to David Krauss from comment #0)
> basic_filebuf (and therefore fstream) does not allow you to put a write
> operation directly after a read operation, or vice versa. Instead, the write
> and the read must be separated by a seek or tell (tell being equivalent to a
> seek-to-current-position).
> 
> As the Standard specifies behavior in terms of the file's contents, the
> current position in the file, and get and put areas, this requirement has no
> basis in it.

I disagree, and would have closed this as INVALID not WONTFIX.

C++14 27.9 [filebuf]:

The restrictions on reading and writing a sequence controlled by an object of
class basic_filebuf<charT, traits> are the same as for reading and writing with
the C standard library FILEs.

C11 7.21.5.3:

When a file is opened with update mode ('+' as the second or third character in
the above list of mode argument values), both input and output may be performed
on the associated stream. However, output shall not be directly followed by
input without an intervening call to the fflush function or to a file
positioning function (fseek, fsetpos, or rewind), and input shall not be
directly followed by output without an intervening call to a file positioning
function, unless the input operation encounters end-of-file.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]