https://gcc.gnu.org/g:f36256c579321165520641f2175c9f957254758b
commit r16-7768-gf36256c579321165520641f2175c9f957254758b Author: lenny.chiadmi-delage <[email protected]> Date: Thu Jan 8 15:13:11 2026 +0000 gccrs: testsuite: Adds test from issue 1245 Added the test from the issue 1245. Fixes GCC-Rust/gccrs#1245 gcc/testsuite/ChangeLog: * rust/execute/issue-1245.rs: New test. Signed-off-by: lenny.chiadmi-delage <[email protected]> Diff: --- gcc/testsuite/rust/execute/issue-1245.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/gcc/testsuite/rust/execute/issue-1245.rs b/gcc/testsuite/rust/execute/issue-1245.rs new file mode 100644 index 000000000000..acfa4d2ebfb8 --- /dev/null +++ b/gcc/testsuite/rust/execute/issue-1245.rs @@ -0,0 +1,31 @@ +// { dg-output "minus two!\r*\nelse\r*\n" } +extern "C" { + fn printf(s: *const i8, ...); +} + +fn foo(x: i32) { + match x { + -2 => { + let a = "minus two!\n\0"; + let b = a as *const str; + let c = b as *const i8; + unsafe { + printf(c); + } + } + _ => { + let a = "else\n\0"; + let b = a as *const str; + let c = b as *const i8; + unsafe { + printf(c); + } + } + } +} + +fn main() -> i32 { + foo(-2); + foo(2); + 0 +}
