Fix the implementation of max_align_t (#1180)
Summary: Folly's `folly/lang/Align.h` header defines `folly::max_align_t`, which is usually taken from stdlib. This is to correct an error in legacy implementations of `std::max_align_t`, by logically reconstructing the maximum alignment value in a constexpr context. `max_align_t` depends on the function `detail::max_align_`, which is supposed to implement a recursive max value function using templates. However, the expression ``` !(a < e) ? a : max_align_(e, es...) ``` does not recursively compute the maximum value over `a`, `e`, `es...`. This expression actually selects the first value that is followed by a lower value. This error prevents folly from compiling on newer versions of clang, targeting x86, because `folly/CachelinePadded.h` statically checks `max_align_t` in an assertion, and then fails, because it thinks that `AtomicStruct<LifoSemHead, atomic>` is over-aligned. This corrects the implementation to: ``` !(a < e) ? max_align_(a, es...) : max_align_(e, es...) ``` Pull Request resolved: https://github.com/facebook/folly/pull/1180 Reviewed By: Orvid Differential Revision: D16079107 Pulled By: yfeldblum fbshipit-source-id: 13adbd6d1c117b3c547e7116216ee1069129b3c7
Showing
Please register or sign in to comment