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
/
slice1.rs
blob
a0488b3912c57fad9ef155b153648a64fe7a9e3c
1
// { dg-additional-options "-w" }
2
struct FatPtr<T> {
3
data: *const T,
4
len: usize,
5
}
6
7
union Repr<T> {
8
rust: *const [T],
9
rust_mut: *mut [T],
10
raw: FatPtr<T>,
11
}
12
13
const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
14
unsafe {
15
let a = FatPtr { data, len };
16
let b = Repr { raw: a };
17
b.rust
18
}
19
}
20
21
fn main() -> i32 {
22
let a = 123;
23
let b: *const i32 = &a;
24
let c = slice_from_raw_parts(b, 1);
25
26
0
27
}