Skip to content

docs: std::slice::from_raw_parts() does not mention that p must be non-null even for zero length slices #26552

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
codyps opened this issue Jun 24, 2015 · 4 comments

Comments

@codyps
Copy link
Contributor

codyps commented Jun 24, 2015

Link to the docs in question: https://doc.rust-lang.org/nightly/std/slice/fn.from_raw_parts.html

@Gankra
Copy link
Contributor

Gankra commented Jun 24, 2015

Is there any API that accepts a null raw pointer?

@bluss
Copy link
Member

bluss commented Jun 24, 2015

What about ptr::copy if the count is zero?

@nagisa
Copy link
Member

nagisa commented Jun 25, 2015

@gankro transmute does :)

println!("{:?}", unsafe { 
    ::std::mem::transmute::<*const u8, Option<&u8>>(::std::ptr::null()) 
});

@Gankra
Copy link
Contributor

Gankra commented Jun 25, 2015

@nagisa I suppose I implicitly meant "explicitly accepts a pointer, and not some opaque T"

steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 8, 2015
Added a proper Unsafety header, as well as mentioning that
the pointer shouldn't be null.

Fixes rust-lang#26552
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 8, 2015
Added a proper Unsafety header, as well as mentioning that
the pointer shouldn't be null.

Fixes rust-lang#26552
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

5 participants