https://bugs.llvm.org/show_bug.cgi?id=39012
Bug ID: 39012
Summary: ostream writes a double that istream can't read
Product: libc++
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: daniel.co...@me.com
CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com
It appears libc++ incorrectly sets input stream failbit when reading subnormal
floating point numbers. Here's an example:
#include <iostream>
#include <string>
#include <sstream>
int main()
{
constexpr double x {1e-320};
std::ostringstream oss {};
oss << x;
const auto str_x = oss.str();
std::istringstream iss {str_x};
double y;
if (iss >> y) {
std::cout << y << std::endl;
} else {
std::cout << "Nope" << std::endl;
}
}
Compiling with Clang/libc++, results in "Nope" being printed, while with
GCC/libstdc++, the value of the double is printed - as I would expect.
I also reported this behaviour in StackOverflow:
https://stackoverflow.com/questions/52410931/why-does-clang-stdostream-write-a-double-that-stdistream-cant-read.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs