Skip to content

Can size_t be 64 bits? #34

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

Closed
dimitri-xyz opened this issue Mar 31, 2020 · 1 comment
Closed

Can size_t be 64 bits? #34

dimitri-xyz opened this issue Mar 31, 2020 · 1 comment

Comments

@dimitri-xyz
Copy link

I believe this will fail if size_t is 64 bits or more and the value is requested is also more than 2^32.

size_t get_power_of_two(size_t n)
{
n--;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
n++;
return n;
}

Adding a similar right shift of 32 bits would solve the problem for situations when size_t has 64 bits.

@ValarDragon
Copy link
Member

Thanks for pointing this out, will fix

ValarDragon added a commit that referenced this issue Aug 25, 2020
ValarDragon added a commit that referenced this issue Sep 25, 2020
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

No branches or pull requests

2 participants