This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++/3720: Problems with num_get


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]