Debian Codegraph @

gcc/testsuite/rust/execute/torture/method1.rs

raw
1 /* { dg-output "124\r*\n458" } */
2 extern "C" {
3 fn printf(s: *const i8, ...);
4 }
5
6 struct Foo(i32);
7 impl Foo {
8 fn bar(&self, i: i32) {
9 unsafe {
10 let a = "%i\n\0";
11 let b = a as *const str;
12 let c = b as *const i8;
13
14 printf(c, self.0 + i);
15 }
16 }
17 }
18
19 fn main() -> i32 {
20 let a = Foo(123);
21 a.bar(1);
22
23 let b = &Foo(456);
24 b.bar(2);
25
26 0
27 }