[libcxx-commits] [PATCH] D70631: Microsoft's floating-point to_chars powered by Ryu and Ryu Printf
Jorg Brown via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 25 16:01:49 PST 2019
jorgbrown added inline comments.
================
Comment at: libcxx/include/xcharconv_ryu.h:193
+ // The casts here help MSVC to avoid calls to the __allmul library function.
+ const uint32_t __aLo = static_cast<uint32_t>(__a);
+ const uint32_t __aHi = static_cast<uint32_t>(__a >> 32);
----------------
zoecarver wrote:
> Is it well-defined behavior to cast from a larger integer to a smaller one?
Yes. See http://eel.is/c++draft/conv#integral which says:
> A prvalue of an integer type can be converted to a prvalue of another integer type. A prvalue of an unscoped enumeration type can be converted to a prvalue of an integer type.
>
> If the destination type is bool, see [conv.bool]. If the source type is bool, the value false is converted to zero and the value true is converted to one.
>
> Otherwise, the result is the unique value of the destination type that is congruent to the source integer modulo N, where N is the width of the destination type.
================
Comment at: libcxx/include/xcharconv_ryu.h:224
+ _LIBCPP_ASSERT(__dist < 64, "");
+#ifdef _WIN64
+ _LIBCPP_ASSERT(__dist > 0, "");
----------------
zoecarver wrote:
> Is there a way this could be generalized to more 64 bit machines?
This is inside of the third-part of a large 3-way #if, where the first of the 3 forks (line 146) handles _M_X64 (MSVC support for Intel x64), and the second of the 3 forks (line 165) handles the availability of __int128 in the compiler. I'm not certain of the existence of 64-bit machines that wouldn't be handled by the those other two forks.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70631/new/
https://reviews.llvm.org/D70631
More information about the libcxx-commits
mailing list