Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions gcc/testsuite/rust/execute/torture/issue-1481.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* { dg-output "called Foo::print\\(\\)\r*" } */
/* { dg-options "-w" } */

#[lang = "sized"]
trait Sized {}

trait Printable {
fn print(&self);
}

struct Foo;

impl Printable for Foo {
fn print(&self) {
// Simulate output
unsafe {
puts("called Foo::print()\0" as *const _ as *const i8);
}
}
}

fn get_printable() -> impl Printable {
Foo
}

extern "C" {
fn puts(s: *const i8);
}

fn main() -> i32 {
let p = get_printable();
p.print();

0
}