Section: 18.104.22.168.3 [istream.extractors] Status: Open Submitter: Richard Smith Opened: 2015-05-08 Last modified: 2017-09-10
View all other issues in [istream.extractors].
View all issues with Open status.
We removed gets() (due to an NB comment and C11 — bastion of backwards compatibility — doing the same). Should we remove this too?Unlike gets(), there are legitimate uses:
char buffer; char text = // ... ostream_for_buffer(text) >> buffer; // ok, can't overrun buffer
… but the risk from constructs like "std::cin >> buffer" seems to outweigh the benefit.The issue had been discussed on the library reflector starting around c++std-lib-35541.
VV: Request a paper to deprecate / remove anything
[2015-10, Kona Saturday afternoon]
STL: This overload is evil and should probably die.
VV: I agree with that, even though I don't care.
STL: Say that we either remove it outright following the gets() rationale, or at least deprecate it.
Move to Open; needs a paper.
[2016-08, Chicago: Zhihao Yuan comments and provides wording]
I would like to keep some reasonable code working;
Reasonable code includes two cases:
width() > 0, any pointer argument
width() >= 0, array argument
For a), banning bad code will become a silent behavior change at runtime; for b), it breaks at compile time.
I propose to replace these signatures with references to arrays. An implementation may want to ship the old instantiatations in the binary without exposing the old signatures.
Tues PM: General agreement on deprecating the unsafe call, but no consensus for the P/R.
General feeling that implementation experience would be useful.
This wording is relative to N4606.
Modify 22.214.171.124.3 [istream.extractors] as indicated:
template<class charT, class traits> basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in,
charT* s); template<class traits> basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char* s); template<class traits> basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char* s);
-7- Effects: Behaves like a formatted input member (as described in 126.96.36.199.1 [istream.formatted.reqmts]) of in. After a sentry object is constructed, operator>> extracts characters and stores them into
successive locations of an array whose first element is designated bys. If width() is greater than zero, n is width(). Otherwise n is the number of elements of the largest array of char_type that can store a terminating charT(). n is the maximum number of characters stored.