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

Writing lots of ZST's is unsound #79

Open
finnbear opened this issue Jan 1, 2025 · 0 comments · May be fixed by #80
Open

Writing lots of ZST's is unsound #79

finnbear opened this issue Jan 1, 2025 · 0 comments · May be fixed by #80

Comments

@finnbear
Copy link

finnbear commented Jan 1, 2025

Hello, I noticed a case in which speedy invokes undefined behavior:

use speedy::Writable;
fn main() {
    let chonk = vec![(); 0x7FFFFFFF_FFFFFFFF + 1];
    let _ = chonk.write_to_vec();
}
error: Undefined Behavior: entering unreachable code
   --> /home/finnb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/speedy-0.8.7/src/writable_impl.rs:245:9
    |
245 |         unsafe_is_length!( self.len() );
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entering unreachable code

I recommend skipping the assertion if std::mem::size_of::<T>() == 0.

@finnbear finnbear linked a pull request Jan 1, 2025 that will close this issue
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.

1 participant