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

Handle 16-bit architectures #3

Open
mbrubeck opened this issue Mar 29, 2017 · 2 comments
Open

Handle 16-bit architectures #3

mbrubeck opened this issue Mar 29, 2017 · 2 comments

Comments

@mbrubeck
Copy link
Owner

Vec32 assumes that casting from u32 to usize is always lossless, which is not true on 8-bit or 16-bit platforms and could cause undefined behavior there.

@setharnold
Copy link

How about 'index' larger than 2^31 on 32 bit platforms?

@mbrubeck
Copy link
Owner Author

mbrubeck commented May 3, 2017

How about 'index' larger than 2^31 on 32 bit platforms?

That would also be bad. Looking closely I don't think it's possible to trigger, because all allocation is done through std::vec::Vec, which panics if it tries to allocate more than isize::MAX bytes. Since cap can never exceed isize::MAX, and len can never exceed cap, the check that index < len is sufficient.

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