[llvm-bugs] [Bug 50916] New: The libc++ library sstream cannot properly process some limit values.

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 27 18:32:46 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50916

            Bug ID: 50916
           Summary: The libc++ library sstream cannot properly process
                    some limit values.
           Product: libc++
           Version: 10.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: 2077213809 at qq.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

I have this use case, when I construct the maximum value of the double type.
After sstream is used to convert a character string to a double type, it is
found that the conversion fails that used libc++. Although value is correctly
assigned, a failure is returned, and libstdc++ is successful.

libc++:
2.22507e-308
error: -2.22507e-308

libstdc++:
2.22507e-308
ok: -2.22507e-308


#include <iostream>
#include <istream>
#include <string>
#include <sstream>
#include <limits>
using namespace std;
int main()
{
  double value;
  string  str = "-2.22507e-308";
  stringstream is(str);
  is << str;
  double minD = std::numeric_limits<double>::min();
  cout << minD << endl;
  if (!(is >> value)) {
     std::cout << "error: " << value << std::endl;
     return 0;
  }
  std::cout << "ok: " << value << std::endl;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210628/f2568704/attachment.html>


More information about the llvm-bugs mailing list