repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
gccrs: Add execution test cases
[official-gcc.git]
/
gcc
/
testsuite
/
rust
/
execute
/
torture
/
issue-1249.rs
blob
072204ea877c255e18fefdcfca8e5e5f318cc6a6
1
// { dg-options "-w" }
2
// { dg-output "1\n2\n" }
3
4
extern "C" {
5
fn printf(s: *const i8, ...);
6
}
7
8
trait T {
9
fn foo(&self);
10
}
11
12
impl dyn T {
13
fn bar(&self) {
14
unsafe {
15
let a = "1\n\0";
16
let b = a as *const str;
17
let c = b as *const i8;
18
printf(c);
19
}
20
self.foo()
21
}
22
}
23
24
struct S;
25
impl T for S {
26
fn foo(&self) {
27
unsafe {
28
let a = "2\n\0";
29
let b = a as *const str;
30
let c = b as *const i8;
31
printf(c);
32
}
33
}
34
}
35
36
pub fn main() -> i32 {
37
<dyn T>::bar(&S);
38
0
39
}