-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
std::slice::from_raw_parts panics (gnu, nightly) if ptr=0, size=0 #120902
Comments
Why are you mentioning the MSVC targets? Does this code not panic on those? |
@saethlin Yup, doesn't panic on stable Am tracking down recent build failures we're seeing in the windows crate https://github.com/microsoft/windows-rs/actions/runs/7851648662/job/21429019066 |
It looks to me like your Beyond that, the precondition that's being checked here is explicitly documented: https://doc.rust-lang.org/stable/std/slice/fn.from_raw_parts.html
|
Right, I was just providing some context as to what I'm doing. I've run the test above locally using stable msvc/gnu with no panics. If this is new expected behavior, happy to close this and we'll guard against the size=0,ptr=0 scenario. |
Yeah; that is the expected behavior. I was just making sure there wasn't anything odd happening with MSVC targets; we have a different check disabled for i686-pc-windows-msvc because MSVC and LLVM disagree about the alignment of You don't see these panics on stable because they were merged yesterday: #120594 I'm always worried when we add checks like this that people will be confused and quiet. Thank you for testing with nightly and getting in touch when you have a question! |
Code
Expected: No panic, aligning with behavior on *-pc-windows-msvc
Actual:
Version it worked on
It most recently worked on:
Version with regression
rustc --version --verbose
:Backtrace
Backtrace
cc: @mati865 @ChrisDenton
The text was updated successfully, but these errors were encountered: