This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/2634
- To: bkoz at gcc dot gnu dot org
- Subject: Re: libstdc++/2634
- From: bkoz at gcc dot gnu dot org
- Date: 2 May 2001 19:26:01 -0000
- Cc: gcc-prs at gcc dot gnu dot org,
- Reply-To: bkoz at gcc dot gnu dot org
The following reply was made to PR libstdc++/2634; it has been noted by GNATS.
From: bkoz@gcc.gnu.org
To: andras.aszodi@pharma.novartis.com, bkoz@gcc.gnu.org,
dirk.steenpass@pharma.novartis.com, gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: libstdc++/2634
Date: 2 May 2001 19:25:18 -0000
Synopsis: istrstream state not correct upon failed conversion
State-Changed-From-To: feedback->closed
State-Changed-By: bkoz
State-Changed-When: Wed May 2 12:25:18 2001
State-Changed-Why:
This code works as expected under current CVS, giving me:
%a.out
i3333333.32 -> X
n3333333.32 -> X
I've ported your code to the new c++ library, the code I used is as below:
// libstdc++/2634
// Try to convert strings starting with 'i' or 'n' to double, you won't get
// the 'X' you should get.
#include <iostream>
#include <sstream>
int main(void)
{
using namespace std;
istringstream istrs01("i3333333.32");
istringstream istrs02("n3333333.32");
// DBL_MAX is printed if conversion fails but stream state remains good.
double Tdouble = DBL_MAX;
if ( istrs01 >> Tdouble)
cout << istrs01.str() <<" -> " << Tdouble << endl;
else
cout << istrs01.str() <<" -> X"<<endl;
if ( istrs02 >> Tdouble)
cout << istrs02.str() <<" -> " << Tdouble << endl;
else
cout << istrs02.str() <<" -> X"<<endl;
return 0;
}
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2634&database=gcc