Closed
Description
This code segfaults at runtime
use std::{
fmt::{self, Debug},
};
trait X {
fn foo(&self) where Self: Debug;
}
impl X for fn(&()) {
fn foo(&self) where fn(&()): Debug {}
}
impl Debug for dyn X {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "hi!")
}
}
pub fn main() {
let x: fn(&()) = |_| ();
let y = &x as &dyn X;
y.foo(); // Segfault at opt-level 0, SIGILL otherwise.
}
cc #48557 - Makes this easier to come across.
Metadata
Metadata
Assignees
Labels
Area: trait objects, vtable layoutArea: Trait systemCategory: This is a bug.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessMedium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.