You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
* microsoft/react-native-windows#4122
* microsoft/react-native-windows#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: facebook/yoga#1154
Reviewed By: Andrey-Mishanin
Differential Revision: D38082048
Pulled By: rozele
fbshipit-source-id: a5da08cfb7d4296c725fb44871c55dbb12dc71e5
0 commit comments