Defect Report #140
Submission Date: 27 Jul 94
Source: Andy Pepperdine
Subclause 22.214.171.124 says:
The setvbuf function may be used only after the stream
... has been associated with an open file and before any other operation
is performed on the stream.
There are two related questions associated with this statement.
1. What does ``performed'' mean?
2. What does ``other operation'' mean?
- Does it include attempts that failed (such as fread on
output file, etc.)?
- In particular, does it include a failed attempt to setvbuf?
- What about fprintf(f, "")?
Reasons for asking:
- Does it include setvbuf itself?
- Are ferror and feof operations?
- What about clearerr?
It would seem reasonable to try to get a very large buffer in some
applications by attempting to do a setvbuf with, say, 1 MB of
buffer space. If that fails, try again with 0.5 MB, etc. Is this allowed?
My guess as to the interpretation is as follows:
1. An operation is ``performed'' even if it fails for whatever
2. All functions defined in subclause 7.9 are to be treated as ``operations.''
This is unsatisfactory, as the above approach of attempting to find
a good buffer size would fail.
In the Rationale, it states ``The general principle is to provide
portable code with a means of requesting the most appropriate popular
buffering style, but not to require an implementation to support
these styles.'' [Emphasis added.]
I interpret this as saying that setvbuf is an advisory call
and need not be acted on. However, my questions above still stand
as there seems to be no way of negotiating an agreement on good acceptable
I believe that a clarification is required.
As you say, ``setvbuf is an advisory call and need not be
acted on.'' That is to say, the C Standard allows it to fail. Therefore,
discussions of detailed constraints such as you describe could only
constitute non-normative advice to programmers or implementers. The
Committee does not have any specific advice to give in this regard.
Previous Defect Report
< - >
Next Defect Report