Title
istream::putback problem
Status
c++20
Section
[istream.unformatted]
Submitter
Juan Soulie

Created on 2013-03-01.00:00:00 last changed 45 months ago

Messages

Date: 2018-03-18.16:03:30

Proposed resolution:

This wording is relative to N4713.

  1. Change [istream.unformatted] as shown:

    basic_istream<charT, traits>& putback(char_type c);
    

    -34- Effects: Behaves as an unformatted input function (as described above), except that the function first clears eofbit. After constructing a sentry object, if !good() calls setstate(failbit) which may throw an exception, and return. If rdbuf() is not null, calls rdbuf()->sputbackc(c). If rdbuf() is null, or if sputbackc() returns traits::eof(), calls setstate(badbit) (which may throw ios_base::failure ([iostate.flags])). [Note: This function extracts no characters, so the value returned by the next call to gcount() is 0. — end note]

    -35- Returns: *this.

    basic_istream<charT, traits>& unget();
    

    -36- Effects: Behaves as an unformatted input function (as described above), except that the function first clears eofbit. After constructing a sentry object, if !good() calls setstate(failbit) which may throw an exception, and return. If rdbuf() is not null, calls rdbuf()->sungetc(). If rdbuf() is null, or if sungetc() returns traits::eof(), calls setstate(badbit) (which may throw ios_base::failure ([iostate.flags])). [Note: This function extracts no characters, so the value returned by the next call to gcount() is 0. — end note]

    -37- Returns: *this.

Date: 2018-03-17.00:00:00

[ 2018-3-17 Adopted in Jacksonville ]

Date: 2017-12-14.00:00:00

[ 2017-12-14 Moved to Tentatively Ready after 6 positive votes on c++std-lib. ]

Date: 2017-12-15.00:00:00

[ 2017-12-12, Jonathan comments and provides wording ]

Fix the bogus expression, and change sputbackc() to just sputbackc since we're talking about the function, not an expression sputbackc() (which isn't a valid expression any more than rdbuf->sputbackc() is). Make the corresponding change to the equivalent wording in p36 too.

Date: 2017-12-13.18:31:35

In [istream.unformatted] / 34, when describing putback, it says that "rdbuf->sputbackc()" is called. The problem are not the obvious typos in the expression, but the fact that it may lead to different interpretations, since nowhere is specified what the required argument to sputbackc is.

It can be guessed to be "rdbuf()->sputbackc(c)", but "rdbuf()->sputbackc(char_type())" or just anything would be as conforming (or non-conforming) as the first guess.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-03-18 16:03:30adminsetmessages: + msg9724
2018-03-18 16:03:30adminsetstatus: voting -> wp
2018-02-12 01:13:49adminsetstatus: ready -> voting
2017-12-14 04:09:16adminsetmessages: + msg9591
2017-12-14 04:09:16adminsetstatus: new -> ready
2017-12-13 18:31:35adminsetmessages: + msg9589
2017-12-13 18:31:35adminsetmessages: + msg9588
2013-03-01 00:00:00admincreate