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 #268, issue with right shift in fast huf decoder #524

Merged
merged 2 commits into from
Aug 15, 2019

Conversation

kdt3rd
Copy link
Contributor

@kdt3rd kdt3rd commented Aug 13, 2019

Technically, doing a logical right shift by the number of bits (or more)
of a number is undefined behaviour. gcc / x86 seems to do (v >>
(shift%bits)), meaning that a right shift of 64 would end up as a right
shift of 0 on a uint64_t value. However, other platforms may shift by
the full number of bits and produce and output 0, not the input. Instead
of leaving this ambiguity, force the 0th value to be manually unrolled /
extracted and to do what was there (and validated by test) as an
undefined behaviour as a more explicit operation.

Signed-off-by: Kimball Thurston kdt3rd@gmail.com

… decoder

Technically, doing a logical right shift by the number of bits (or more)
of a number is undefined behaviour. gcc / x86 seems to do (v >>
(shift%bits)), meaning that a right shift of 64 would end up as a right
shift of 0 on a uint64_t value. However, other platforms may shift by
the full number of bits and produce and output 0, not the input. Instead
of leaving this ambiguity, force the 0th value to be manually unrolled /
extracted and to do what was there (and validated by test) as an
undefined behaviour as a more explicit operation.

Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
@kdt3rd kdt3rd merged commit 4f81370 into AcademySoftwareFoundation:master Aug 15, 2019
@kdt3rd kdt3rd deleted the fix_268 branch August 15, 2019 09:34
@cary-ilm cary-ilm added this to the v2.4.0 milestone Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants