Closed
Description
When compiling with LTO enabled, CStr::from_bytes_with_nul(b"\0") returns an error. Without LTO, it returns Ok. The former result seems incorrect. The following terminal session should help illustrate:
% cat testing.rs
use std::ffi::CStr;
fn main()
{
println!("{:?}", CStr::from_bytes_with_nul(b"\0"));
}
% rustc testing.rs -C opt-level=3 -C lto
% ./testing
Err(FromBytesWithNulError { _a: () })
% rustc testing.rs -C opt-level=3
% ./testing
Ok("")
% rustc --version
rustc 1.15.1 (021bd294c 2017-02-08)