Fix Yoga's conditional use of std::bit_cast<>()
Summary: Yoga tries to use `std::bit_cast<>()` where it's available and falls back to `std::memcpy()` everywhere else. Unfortunately, the feature-test macro (`__cpp_lib_bit_cast`) is only defined if the feature is available *and you have already included either `<version>` or `<bit>`* (or something else that includes one of those). Since `CompactValue.h` checks `__cpp_lib_bit_cast` *first*, it's not defined even if it *would be* defined, leading the header not to `#include <bit>`, leaving `std::bit_cast<>()` undefined; later, other headers from the STL are included, leading to `__cpp_lib_bit_cast` *becoming* defined and causing later code to choose to use the undefind `std::bit_cast<>()`. This diff fixes the problem by `#include`ing either `<version>` or `<ciso646>` (depending on availability) before checking any feature-test macros. Changelog: [Internal] Reviewed By: smeenai Differential Revision: D41641205 fbshipit-source-id: 7d7bc5791c902a45302d3707e6cbf21fc0493f0c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
49af711502
commit
707115ee7e
@@ -9,6 +9,14 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#if defined(__has_include) && __has_include(<version>)
|
||||
// needed to be able to evaluate defined(__cpp_lib_bit_cast)
|
||||
#include <version>
|
||||
#else
|
||||
// needed to be able to evaluate defined(__cpp_lib_bit_cast)
|
||||
#include <ciso646>
|
||||
#endif
|
||||
|
||||
#ifdef __cpp_lib_bit_cast
|
||||
#include <bit>
|
||||
#else
|
||||
|
Reference in New Issue
Block a user