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

[range_api] Fix bitwise shift rhs out-of-range #983

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

wenju-he
Copy link
Contributor

@wenju-he wenju-he commented Nov 12, 2024

In function test_range_kernels, range[2] is 64 and range_two[2] is 128. It is undefined behavior to use either of them as rhs of bitwise shift operator because the rhs is not smaller than the number of bits in range value type. This PR divides rhs by 4 so that it is smaller than 64.

In kernel test_range_kernels, range[2] is 64 and range_two[2] is 128.
It is undefined behavior to use either of them as rhs of bitwise shift
operator because the rhs is not smaller than the number of bits in range
value type. This PR divides rhs by 4 so that it is smaller than 64.
@wenju-he wenju-he requested a review from a team as a code owner November 12, 2024 07:14
@keryell
Copy link
Member

keryell commented Nov 13, 2024

In function test_range_kernels, range[2] is 64 and range_two[2] is 128. It is undefined behavior to use either of them as rhs of bitwise shift operator because the rhs is not smaller than the number of bits in range value type. This PR divides rhs by 4 so that it is smaller than 64.

Great catch! Could you copy your analysis as a comment close to where the ranges are defines?
Otherwise we will forget about it and its rationale.

@wenju-he
Copy link
Contributor Author

Great catch! Could you copy your analysis as a comment close to where the ranges are defines? Otherwise we will forget about it and its rationale.

done.

Copy link
Member

@keryell keryell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bader bader merged commit a0b35ca into KhronosGroup:main Nov 13, 2024
8 checks passed
@wenju-he wenju-he deleted the range_api-bitwise-shift-rhs branch November 14, 2024 00:00
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