[libcxx-commits] [libcxx] [libc++] LWG2381: Inconsistency in parsing floating point numbers (PR #77948)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 7 10:22:23 PDT 2024


================
@@ -165,9 +170,129 @@ int main(int, char**)
             f.get(cpp17_input_iterator<const char*>(str),
                   cpp17_input_iterator<const char*>(str+sizeof(str)),
                   ios, err, v);
-        assert(base(iter) == str+sizeof(str)-1);
-        assert(err == ios.goodbit);
-        assert(std::isnan(v));
+        assert(base(iter) == str);
+        assert(err == ios.failbit);
+        assert(v == 0.0f);
+    }
+    {
+      const char str[] = "p00";
+      std::hex(ios);
+      std::ios_base::iostate err             = ios.goodbit;
+      cpp17_input_iterator<const char*> iter = f.get(
+          cpp17_input_iterator<const char*>(str), cpp17_input_iterator<const char*>(str + sizeof(str)), ios, err, v);
+      assert(base(iter) == str);
+      assert(err == ios.failbit);
+      assert(v == 0.0);
----------------
mordante wrote:

For consistency with the existing code.
```suggestion
      assert(v == 0.0f);
```

Please make a similar changes for the new `long double` tests.

https://github.com/llvm/llvm-project/pull/77948


More information about the libcxx-commits mailing list