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 bug on casting double to uint_64 #6067

Closed
wants to merge 1 commit into from
Closed

Conversation

lbianc
Copy link
Contributor

@lbianc lbianc commented Aug 19, 2015

When 'v' is equal to 'std::numeric_limits<uint64_t>::max()', it should not be
casted to uint64_t, because there will be an overflow.
For x86_64 machines, the cast above results in overflow, but the result is
'0', i. e., the expected result.
Others platforms may not behave the same way, as tested on PPC64, that returns
'-1' for the same cast.
Looking for make HHVM behave the same way in both platforms, this change
returns '0' if the number going to be casted ('v') is equal to
'std::numeric_limits<uint64_t>::max()'. There is no behavior change for x86_64
platform.
See discussion: #5932.
PS: tested on php5 v5.6.9-1 on PPC64 and that result is also supposed to be ‘0’,
not ‘-1’.

When 'v' is equal to 'std::numeric_limits<uint64_t>::max()', it should not be
casted to uint64_t, because there will be an overflow.
For x86_64 machines, the cast above results in overflow, but the result is
'0', i. e., the expected result.
Others platforms may not behave the same way, as tested on PPC64, that returns
'-1' for the same cast.
Looking for make HHVM behave the same way in both platforms, this change
returns '0' if the number going to be casted ('v') is equal to
'std::numeric_limits<uint64_t>::max()'. There is no behavior change for x86_64
platform.
See discussion: facebook#5932.
PS: tested on php5 v5.6xxx on PPC64 and that result is also supposed to be ‘0’,
not ‘-1’.
@facebook-github-bot
Copy link
Contributor

This pull request has been imported into Phabricator, and discussion and review of the diff will take place at https://reviews.facebook.net/D44925

@lbianc
Copy link
Contributor Author

lbianc commented Aug 28, 2015

Any comment regarding this PR? Can it be merged?

@hhvm-bot hhvm-bot closed this in 6d27429 Sep 3, 2015
@gut gut deleted the cast branch December 22, 2015 17:20
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