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

CStr::from_bytes_with_nul(b"\0") return value changes when compiling with LTO #40165

Closed
aprilwade opened this issue Feb 28, 2017 · 4 comments
Closed
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@aprilwade
Copy link

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)
@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 1, 2017
@alexcrichton
Copy link
Member

I believe this is an upstream LLVM bug, unfortunately

@arielb1
Copy link
Contributor

arielb1 commented Mar 3, 2017

@Mark-Simulacrum
Copy link
Member

The bug was fixed in LLVM recently; do we want to do a backport of their patch?

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
@kennytm kennytm added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Nov 15, 2017
@alexcrichton
Copy link
Member

Fixed in #47828

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants