Closed
Description
I tried this code with ASAN nightly rust (https://godbolt.org/z/KE6P9xYsY):
// Doesn't fail without -Copt-level=0
#[repr(C)] // doesn't fail without this
#[derive(Clone, Debug)]
pub enum A {
A(i8),
}
#[repr(C)] // doesn't fail without this
pub enum B {
B(A),
}
// doesn't fail if extern "C" is dropped
pub extern "C" fn f(b: B) -> A {
let a = match b {
B::B(a) => Some(a),
};
a.unwrap()
}
fn main() {
let b = B::B(A::A(3));
// doesn't fail if the body of f is inlined.
let a = f(b);
println!("a: {:?}", &a);
}
I expected to see this happen: program executes successfully.
Instead, this happened: program failed with ASAN warning.
Meta
Requires nightly with -Zsanitizer=address --target x86_64-unknown-linux-gnu -Copt-level=0
: https://godbolt.org/z/KE6P9xYsY.
It looks this is not a recent regression, it's present in rust from 2021.
% export dt=2021-06-10 ; rustup install nightly-$dt && rustc +nightly-$dt -Zsanitizer=address --target x86_64-unknown-linux-gnu -Copt-level=0 -g main.rs && ./main
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generationArea: Sanitizers for correctness and code qualityCategory: This is a bug.Category: An issue highlighting optimization opportunities or PRs implementing suchIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessRelevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.