This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/27904] New: operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: "ian at airs dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jun 2006 20:44:58 -0000
- Subject: [Bug libstdc++/27904] New: operator>> to floating point variable does not support "inf", "infinity", or "nan"
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
On GNU/Linux, and several other operating systems, the strtod function will
accept the strings "inf" and "infinity" for an infinite value, and the string
"nan" for a NaN (the tests are case insensitive). This is a convenient way to
specify an infinite or NaN floating point value from the command line or in an
input file.
Unfortunately, this does not work with operator>> in the current libstdc++.
Here is a test case which I believe should pass, as a quality of implementation
issue. It currently aborts. I haven't yet tested it with libstdc++ v2, but
inspection suggests that it would have worked.
#include <sstream>
#include <cmath>
int
main ()
{
std::istringstream sinf ("inf");
double d;
sinf >> d;
if (!sinf || !isinf (d))
abort ();
std::istringstream sinfinity ("infinity");
sinfinity >> d;
if (!sinfinity || !isinf (d))
abort ();
std::istringstream snan ("nan");
snan >> d;
if (!snan || !isnan (d))
abort ();
exit (0);
}
--
Summary: operator>> to floating point variable does not support
"inf", "infinity", or "nan"
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27904
- Follow-Ups:
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pcarlini at suse dot de
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pinskia at gcc dot gnu dot org
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pcarlini at suse dot de
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pinskia at gcc dot gnu dot org
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pinskia at gcc dot gnu dot org
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pinskia at gcc dot gnu dot org
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pcarlini at suse dot de
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pcarlini at suse dot de
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pinskia at gcc dot gnu dot org
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pcarlini at suse dot de
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: ian at airs dot com
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pcarlini at suse dot de
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: ian at airs dot com
- [Bug libstdc++/27904] operator>> to floating point variable does not support "inf", "infinity", or "nan"
- From: pcarlini at suse dot de