[libc-commits] [PATCH] D113790: [libc] fix strtof/d/ld NaN parsing

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Nov 15 10:44:45 PST 2021

michaelrj added inline comments.

Comment at: libc/src/__support/str_to_float.h:794
+          char *tempSrc = 0;
+          if (isdigit(*(parenStart + 1))) {
+            // This is to prevent errors when BitsType is larger than 64 bits,
sivachandra wrote:
> Add a var named `numberStart` to avoid repeated `parentStart + 1`?
While that is possible, I'm not sure if it would help. Currently `parenStart + 1` is only used twice, so I don't think defining a new variable would be useful. Instead I renamed the variable to be `leftParen`, so that it's more clear that it points to the left parenthesis.

Comment at: libc/test/src/stdlib/strtof_test.cpp:163
   runTest("NaN( 1234)", 3, 0x7fc00000);
+  runTest("NaN(asdf)", 9, 0x7fc00000);
sivachandra wrote:
> Add a comment explaining whats going on here and in the above line?
Should be more clear now.

  rG LLVM Github Monorepo



More information about the libc-commits mailing list