https://gcc.gnu.org/g:a0b8b76c8cf32a6a12fe6ca4b3fce847efa5495f
commit r16-2882-ga0b8b76c8cf32a6a12fe6ca4b3fce847efa5495f Author: Philip Herron <herron.phi...@googlemail.com> Date: Thu Jun 19 19:37:10 2025 +0100 gccrs: Add test case showing RPIT working to close issue Fixes Rust-GCC#1486 gcc/testsuite/ChangeLog: * rust/execute/torture/issue-1481.rs: New test. Signed-off-by: Philip Herron <herron.phi...@googlemail.com> Diff: --- gcc/testsuite/rust/execute/torture/issue-1481.rs | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gcc/testsuite/rust/execute/torture/issue-1481.rs b/gcc/testsuite/rust/execute/torture/issue-1481.rs new file mode 100644 index 000000000000..2ff78d9b6055 --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/issue-1481.rs @@ -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 +}