libstdc++/3720: Problems with num_get

Peter Schmid schmid@snake.iap.physik.tu-darmstadt.de
Sat Dec 1 10:09:00 GMT 2001


Dear Mr Kosnik,

your proposal is reasonable as far as I understand it.

STLport-4.5, the other libstdc++ implementation I have access to,
restricts the input field for integers to ten decimals, as
defined by the digits10 member, and sets the failbit if there are more
than ten digits on input. 

Consider the following source code tcin.C

#include <iostream>
using namespace std;

int main()
{
    cout<<"rdstate before reading from cin : "
        << cin.rdstate() << endl;
    cout<<"good eof fail bad "
        << ios::goodbit << " "
        << ios::eofbit << " "
        << ios::failbit << " "
        << ios::badbit << endl;

  int i;
  cin >> i;
  cout << "cin state: " << cin.rdstate() << endl;
  cout << "i: " << i << endl;
}

./tcin
rdstate before reading from cin : 0
good eof fail bad 0 2 4 1
1234567890
cin state: 0
i: 1234567890
peter@kiste:~> !!
./tcin
rdstate before reading from cin : 0
good eof fail bad 0 2 4 1
12345678901
cin state: 4
i: 2147483647

Hope this helps,

Peter Schmid



More information about the Gcc-bugs mailing list