Fix the implementation of max_align_t in lang/Align.h.#1180
Conversation
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
yfeldblum
left a comment
There was a problem hiding this comment.
Yikes! Thanks for the PR.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@yfeldblum has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
Thanks! |
|
@yfeldblum merged this pull request in 72c08f7. |
Folly's Align.h header overwrites
max_align_t, which is usually taken from stdlib. This is to correct an error in legacy implementations ofmax_align_t, by logically reconstructing the maximum alignment value in a constexpr.max_align_t depends on the function
folly::details::max_align_, which is supposed to implement a recursive max value function using templates. However, the expressiondoes not recursively compute the maximum value over
eandes...This implementation actually selects the first value of
eandes...that is followed by a lower value.The correct implementation is provided in this pull request.
This error prevents folly from compiling on newer versions of clang, targeting x86, because CachelinePadded.h statically checks max_align_t in an assertion, and then fails, because it thinks that AtomicStruct<LifoSemHead, atomic> is over-aligned.