Title
Need error indication from seekp() and seekg()
Status
tc1
Section
[istream.unformatted] [ostream.seeks]
Submitter
Angelika Langer

Created on 1999-02-22.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

Setting failbit is the usual error reporting mechanism for streams

Date: 2010-10-21.18:28:33

Proposed resolution:

Add to the Effects: clause of  seekg() in [istream.unformatted] and to the Effects: clause of seekp() in [ostream.seeks]:

In case of failure, the function calls setstate(failbit) (which may throw ios_base::failure).

Date: 1999-02-22.00:00:00

Currently, the standard does not specify how seekg() and seekp() indicate failure. They are not required to set failbit, and they can't return an error indication because they must return *this, i.e. the stream. Hence, it is undefined what happens if they fail. And they can fail, for instance, when a file stream is disconnected from the underlying file (is_open()==false) or when a wide character file stream must perform a state-dependent code conversion, etc.

The stream functions seekg() and seekp() should set failbit in the stream state in case of failure.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg1468
2010-10-21 18:28:33adminsetmessages: + msg1467
1999-02-22 00:00:00admincreate