[libcxx-commits] [PATCH] D131336: [libc++][test] Fix MSVC warnings C6054, C6001, C4242 and -NaN is formatted differently on MSVC

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Aug 6 11:46:44 PDT 2022


Mordante requested changes to this revision.
Mordante added a comment.
This revision now requires changes to proceed.

Also I found something else.
Currently this test fails on MSVC with

  Format string   answer is '{:#g}'
  Expected output answer is '0.'
  Actual output   answer is '0.00000'

This seems like a bug, looking at http://eel.is/c++draft/format#string.std-6 the trailing zeros should remain. It seems I missed that. Good catch.

For now I put this on request changes to remove it from the review queue, so we can discuss what to do about the NaNs.



================
Comment at: libcxx/test/std/utilities/format/format.functions/format_tests.h:1032
+#else
+  check.template operator()<"answer is '{:0>12a}'">(SV("answer is '000-nan(ind)'"), nan_neg);
+  check.template operator()<"answer is '{:0<12a}'">(SV("answer is '-nan(ind)000'"), nan_neg);
----------------
MSVC STL is wrong per
http://eel.is/c++draft/format#string.std-22

I added code to not directly use the result of `std::to_chars` since I know it can give the "wrong" results.
https://github.com/llvm/llvm-project/blob/main/libcxx/include/__format/formatter_floating_point.h#L582

But let's discuss this further on MSVC STL's Discord.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131336/new/

https://reviews.llvm.org/D131336



More information about the libcxx-commits mailing list