This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++14 status.
basic_ostream::seekp(pos) andbasic_ostream::seekp(off, dir)Section: 31.7.6.2.5[ostream.seeks]Status:C++14Submitter: Marshall ClowOpened: 2013-10-21Last modified: 2017-07-05
Priority:0
View all issues withC++14 status.
Discussion:
In 31.7.6.2.5[ostream.seeks], we have:
basic_ostream<charT,traits>& seekp(pos_type pos);-3-Effects: If
-4-Returns:fail() != true, executesrdbuf()->pubseekpos(pos, ios_base::out). In case of failure, the function callssetstate(failbit)(which may throwios_base::failure).*this.
basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir);-5-Effects: If
-6-Returns:fail() != true, executesrdbuf()->pubseekoff(off, dir, ios_base::out).*this.
The first call is required to set thefailbit on failure, but the second is not
os1 andos2) the following code (confusingly) works:os1.seekp(-1);assert(os1.fail());os2.seekp(-1, std::ios_base::beg);assert(os2.good());
Note that the description ofbasic_istream<charT,traits>& seekg(off_type off, ios_base::seekdir dir) in 31.7.5.4[istream.unformatted] p43does require settingfailbit.
[Issaquah 2014-02-11: Move to Immediate]
Proposed resolution:
This wording is relative to N3797.
Modify 31.7.6.2.5[ostream.seeks]p5 as indicated:
basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir);-5-Effects: If
-6-Returns:fail() != true, executesrdbuf()->pubseekoff(off, dir, ios_base::out).In case of failure, the function callssetstate(failbit)(which may throwios_base::failure).*this.