Closed
Description
I tried this code:
struct T;
trait TT {
fn foo(&self);
}
impl TT for T {
fn foo(&self) {
println!("foo");
}
}
fn main() {
let x = T;
let y = &x as &dyn TT;
y.foo();
}
I expected to see this happen: "foo" should be printed and the program should exit, as in
mmaurer@curtana:~/printer$ cargo run
Compiling printer v0.1.0 (/usr/local/google/home/mmaurer/printer)
Finished dev [unoptimized + debuginfo] target(s) in 0.29s
Running `target/debug/printer`
foo
mmaurer@curtana:~/printer$
Instead, this happened: "Illegal instruction" is printed as the program has received a SIGILL
mmaurer@curtana:~/printer$ RUSTFLAGS="-Zsanitizer=cfi -C lto -Cembed-bitcode=yes" cargo run
Compiling printer v0.1.0 (/usr/local/google/home/mmaurer/printer)
Finished dev [unoptimized + debuginfo] target(s) in 2.51s
Running `target/debug/printer`
Illegal instruction
mmaurer@curtana:~/printer$ echo $?
132
mmaurer@curtana:~/printer$
Meta
rustc --version --verbose
:
rustc 1.68.0-nightly (388538fc9 2023-01-05)
binary: rustc
commit-hash: 388538fc963e07a94e3fc3ac8948627fd2d28d29
commit-date: 2023-01-05
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6