This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.
Section: 31.10.2.5 [filebuf.virtuals] Status: CD1 Submitter: Dietmar Kühl Opened: 1999-07-20 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [filebuf.virtuals].
View all issues with CD1 status.
Discussion:
Overridden virtual functions, seekpos()
In 31.10.2 [filebuf] paragraph 3, it is stated that a joint input and output position is maintained by basic_filebuf. Still, the description of seekpos() seems to talk about different file positions. In particular, it is unclear (at least to me) what is supposed to happen to the output buffer (if there is one) if only the input position is changed. The standard seems to mandate that the output buffer is kept and processed as if there was no positioning of the output position (by changing the input position). Of course, this can be exactly what you want if the flag ios_base::ate is set. However, I think, the standard should say something like this:
Plus the appropriate error handling, that is...
Proposed resolution:
Change the unnumbered paragraph in 27.8.1.4 (lib.filebuf.virtuals) before paragraph 14 from:
pos_type seekpos(pos_type sp, ios_base::openmode = ios_base::in | ios_base::out);
Alters the file position, if possible, to correspond to the position stored in sp (as described below).
- if (which&ios_base::in)!=0, set the file position to sp, then update the input sequence
- if (which&ios_base::out)!=0, then update the output sequence, write any unshift sequence, and set the file position to sp.
to:
pos_type seekpos(pos_type sp, ios_base::openmode = ios_base::in | ios_base::out);
Alters the file position, if possible, to correspond to the position stored in sp (as described below). Altering the file position performs as follows:
1. if (om & ios_base::out)!=0, then update the output sequence and write any unshift sequence;
2. set the file position to sp;
3. if (om & ios_base::in)!=0, then update the input sequence;
where om is the open mode passed to the last call to open(). The operation fails if is_open() returns false.
[Kona: Dietmar is working on a proposed resolution.]
[Post-Tokyo: Dietmar supplied the above wording.]