Closed
Description
mmaurer@anyblade:~/github/rust-lang$ rustc -Z sanitizer=cfi -C lto -C codegen-units=1 badsample.rs
mmaurer@anyblade:~/github/rust-lang$ ./badsample
Illegal instruction
mmaurer@anyblade:~/github/rust-lang$ rustc -C lto -C codegen-units=1 badsample.rs
mmaurer@anyblade:~/github/rust-lang$ ./badsample
mmaurer@anyblade:~/github/rust-lang$ cat badsample.rs
trait Foo {
fn foo(&self);
}
struct S;
impl Foo for S {
fn foo(&self) {}
}
struct S2 {
f: fn(&S)
}
impl S2 {
fn foo(&self, s: &S) {
(self.f)(s)
}
}
fn main() {
S2 { f: <S as Foo>::foo }.foo(&S)
}
This appears to happen because <S as Foo>::foo
has CFI-type fn(&dyn Foo)
rather than fn(&S)
.
cc @rcvalle