Rewrite CompactValue to avoid undefined behavior from the use of a union for type-punning (#1154)
Rewrite CompactValue to avoid undefined behavior from the use of a union for type-punning (#1154)

Summary:
C++ does not, pedantically, allow the use of unions for type-punning in the way that C does. Most compilers, in practice, do support it; however, recent versions of MSVC appear to have a bug that cause bad code to be generated due to this U.B. (see: https://developercommunity.visualstudio.com/t/Bad-code-generated-for-std::isnan-compil/10082631). This led to a series of issues in the react-native-windows project, see:
* https://github.com/microsoft/react-native-windows/issues/4122
* https://github.com/microsoft/react-native-windows/issues/8675

In C++20, the `<bit>` header and `bit_cast` function provide a pleasant API for type-punning. Since C++20 is not universally available, if the feature-test macro for `bit_cast` is not defined, memcpy is used instead.

X-link: https://github.com/facebook/yoga/pull/1154

Reviewed By: Andrey-Mishanin

Differential Revision: D38082048

Pulled By: rozele

fbshipit-source-id: a5da08cfb7d4296c725fb44871c55dbb12dc71e5

facebook/react-native,javache/react-native,janicduplessis/react-native,janicduplessis/react-native,facebook/react-native,facebook/react-native,javache/react-native,janicduplessis/react-native,janicduplessis/react-native,javache/react-native,janicduplessis/react-native,javache/react-native,janicduplessis/react-native,javache/react-native,javache/react-native,facebook/react-native,javache/react-native,janicduplessis/react-native,javache/react-native,javache/react-native,facebook/react-native,facebook/react-native,janicduplessis/react-native,facebook/react-native,facebook/react-native,facebook/react-native