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

Test that derived code works with std::mem::transmute #35

Open
turalcar opened this issue Mar 26, 2024 · 0 comments
Open

Test that derived code works with std::mem::transmute #35

turalcar opened this issue Mar 26, 2024 · 0 comments

Comments

@turalcar
Copy link

The main offender is download_more_ram() that converts 0 to a pointer.

let sentinel_slice = crate::transmute::<_, &[u8]>([0usize, 1usize]);

With std::mem::transmute this causes time-travelling UB: compiler concludes that the only way we could get 0 here is by failing unwrap() few lines prior. The simple solution would be to use 1usize and 2usize to deduce the slice pointer layout or just assume that the pointer goes first - it's not the end of the world.
This prevents removing #[inline(never)] in the implementation of transmute().

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

1 participant