Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1110, 32-bit build failure on Mac OSX #1112

Merged
merged 1 commit into from
May 2, 2016

Conversation

warrenfalk
Copy link
Contributor

@warrenfalk warrenfalk commented Apr 30, 2016

Using explicit 64-bit type in conditional in platforms above 32-bits

std::conditional does not appear to short circuit before evaluating the third template arg which results in an error because the constant value does not fit in a 32-bit size_t. This is a warning in a linux environment but an error in Mac OSX

The solution is to just make the third argument type explicitly 64-bit. The entire expression then either becomes a 32-bit constant or a 64-bit constant holding a 32-bit value, but in either case is assignable to a 32-bit size_t.

This works correctly in the following cases:
32-bit: a 32-bit value will be assigned to a 32-bit size_t.
64-bit: size_t and uint64_t are the same size so the assignment is fine.

64-bit: size_t is larger than uint64_t so the assignment is fine.

Using explicit 64-bit type in conditional in platforms above 32-bits
This appears to be necessary on Mac OSX as std::conditional does not appear to short circuit and evaluates the third template arg
Making the third template arg be 64 bits explicitly works around this problem and will work on both 32 bit and 64+ bit platforms.
@ghost ghost added the CLA Signed label Apr 30, 2016
@igorcanadi
Copy link
Collaborator

Thanks @warrenfalk !

@igorcanadi igorcanadi merged commit b8cf913 into facebook:master May 2, 2016
yiwu-arbug pushed a commit that referenced this pull request May 2, 2016
Using explicit 64-bit type in conditional in platforms above 32-bits
This appears to be necessary on Mac OSX as std::conditional does not appear to short circuit and evaluates the third template arg
Making the third template arg be 64 bits explicitly works around this problem and will work on both 32 bit and 64+ bit platforms.
@warrenfalk warrenfalk deleted the fix32_2 branch May 4, 2016 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants