Debian Codegraph @

gcc/testsuite/rust/execute/torture/str-zero.rs

raw
1 /* { dg-output "bar foo baz foobar\r*\n" } */
2 extern "C" {
3 fn printf(s: *const i8, ...);
4 fn memchr(s: *const i8, c: u8, n: usize) -> *const i8;
5 }
6
7 pub fn main() -> i32 {
8 let f = "%s %s %s %s\n\0";
9 let s = "bar\0\
10 foo\
11 \x00\
12 baz\u{0000}\
13 foobar\0";
14 let cf = f as *const str as *const i8;
15 let cs = s as *const str as *const i8;
16 unsafe {
17 let cs2 = memchr(cs, b'f', 5);
18 let cs3 = memchr(cs2, b'b', 5);
19 let cs4 = memchr(cs3, b'f', 5);
20 printf(cf, cs, cs2, cs3, cs4);
21 }
22 0
23 }