This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofTC1 status.
Section: 27.4.4.4[string.io]Status:TC1Submitter: Scott SnyderOpened: 2000-02-04Last modified: 2016-01-28
Priority:Not Prioritized
View all otherissues in [string.io].
View all issues withTC1 status.
Discussion:
The description of the stream extraction operator for std::string (section21.3.7.9 [lib.string.io]) does not contain a requirement that failbit be set inthe case that the operator fails to extract any characters from the inputstream.
This implies that the typical construction
std::istream is;std::string str;...while (is >> str) ... ;
(which tests failbit) is not required to terminate at EOF.
Furthermore, this is inconsistent with other extraction operators,which do include this requirement. (See sections 31.7.5.3[istream.formatted] and 31.7.5.4[istream.unformatted]), where thisrequirement is present, either explicitly or implicitly, for theextraction operators. It is also present explicitly in the descriptionof getline (istream&, string&, charT) in section 27.4.4.4[string.io] paragraph 8.)
Proposed resolution:
Insert new paragraph after paragraph 2 in section 27.4.4.4[string.io]:
If the function extracts no characters, it callsis.setstate(ios::failbit) which may throw ios_base::failure(27.4.4.3).