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

Feature request: Report capacity 0 instead of panick when alignment isn't satisfied #22

Closed
juchiast opened this issue Apr 6, 2021 · 4 comments · Fixed by #23
Closed

Comments

@juchiast
Copy link

juchiast commented Apr 6, 2021

Currently, it is not possible to use im to store i64, f64, etc. on architectures where usize alignment is less than 8, such as WASM and arm32 (bodil/im-rs#174).

I think InlineArray should report capacity 0 instead of panicking to support more architectures.

@juchiast juchiast changed the title Feature request: Feature request: Report capacity 0 instead of panick when aligment isn't satisfied Apr 6, 2021
@juchiast juchiast changed the title Feature request: Report capacity 0 instead of panick when aligment isn't satisfied Feature request: Report capacity 0 instead of panick when alignment isn't satisfied Apr 6, 2021
@kornelski
Copy link
Collaborator

You can use the backing storage type T to get bigger alignment, i.e. instead of storing i64 in [u8; 8], you can store it in [i64; 1].

@juchiast
Copy link
Author

juchiast commented Apr 6, 2021

Thanks! I uses this indirectly through im, so I don't have much control to get around the issue.

@juchiast
Copy link
Author

juchiast commented Apr 6, 2021

I could use #[repr(packed)] on my struct to reduce the alignment, but unfortunately it also needs #[derive(Deserialize)], and it is not possible to derive on packed and !Copy types at the moment.

@bodil
Copy link
Owner

bodil commented Apr 6, 2021

Almost sounds to me like it's worth making the InlineArray itself align 8, to lessen the risk of misalignment.

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 a pull request may close this issue.

3 participants