This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/86409] New: std::stod fails for denormal numbers
- From: "b7.10110111 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 05 Jul 2018 11:21:01 +0000
- Subject: [Bug libstdc++/86409] New: std::stod fails for denormal numbers
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86409
Bug ID: 86409
Summary: std::stod fails for denormal numbers
Product: gcc
Version: 8.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: b7.10110111 at gmail dot com
Target Milestone: ---
Consider the following test program:
// BEGIN
#include <iostream>
#include <sstream>
int main()
{
const char str[]="3.23534634e-320";
try
{
const auto value=std::stod(str);
std::cout << "stod returned " << value << '\n';
}
catch(std::exception&)
{
std::cerr << "stod failed\n";
}
std::istringstream ss(str);
double value;
ss >> value;
if(ss) std::cout << "istringstream gave " << value << '\n';
else std::cerr << "istringstream failed\n";
}
// END
Here std::stod throws std::out_of_range exception, although the number can be
represented as a denormal in double. std::istringstream works as expected,
reading the denormal into the variable.