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.

49. Underspecification of ios_base::sync_with_stdio

Section: [ios.members.static] Status: CD1 Submitter: Matt Austern Opened: 1998-06-21 Last modified: 2016-01-28

Priority: Not Prioritized

View all issues with CD1 status.


Two problems

(1) doesn't say what ios_base::sync_with_stdio(f) returns. Does it return f, or does it return the previous synchronization state? My guess is the latter, but the standard doesn't say so.

(2) doesn't say what it means for streams to be synchronized with stdio. Again, of course, I can make some guesses. (And I'm unhappy about the performance implications of those guesses, but that's another matter.)

Proposed resolution:

Change the following sentence in [ios.members.static] returns clause from:

true if the standard iostream objects (27.3) are synchronized and otherwise returns false.


true if the previous state of the standard iostream objects (27.3) was synchronized and otherwise returns false.

Add the following immediately after [ios.members.static], paragraph 2:

When a standard iostream object str is synchronized with a standard stdio stream f, the effect of inserting a character c by

  fputc(f, c);

is the same as the effect of


for any sequence of characters; the effect of extracting a character c by

  c = fgetc(f);

is the same as the effect of:

  c = str.rdbuf()->sbumpc(c);

for any sequences of characters; and the effect of pushing back a character c by

  ungetc(c, f);

is the same as the effect of


for any sequence of characters. [Footnote: This implies that operations on a standard iostream object can be mixed arbitrarily with operations on the corresponding stdio stream. In practical terms, synchronization usually means that a standard iostream object and a standard stdio object share a buffer. --End Footnote]

[pre-Copenhagen: PJP and Matt contributed the definition of "synchronization"]

[post-Copenhagen: proposed resolution was revised slightly: text was added in the non-normative footnote to say that operations on the two streams can be mixed arbitrarily.]