]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
c34b1796 | 11 | |
1a4d82fc JJ |
12 | #![feature(intrinsics)] |
13 | ||
14 | use std::ptr; | |
15 | ||
16 | struct Point { | |
17 | x: f32, | |
18 | y: f32, | |
19 | z: f32, | |
20 | } | |
21 | ||
22 | extern "rust-intrinsic" { | |
23 | fn return_address() -> *const u8; | |
24 | } | |
25 | ||
c34b1796 | 26 | fn f(result: &mut usize) -> Point { |
1a4d82fc | 27 | unsafe { |
c34b1796 | 28 | *result = return_address() as usize; |
1a4d82fc JJ |
29 | Point { |
30 | x: 1.0, | |
31 | y: 2.0, | |
32 | z: 3.0, | |
33 | } | |
34 | } | |
35 | ||
36 | } | |
37 | ||
38 | fn main() { | |
39 | let mut intrinsic_reported_address = 0; | |
40 | let pt = f(&mut intrinsic_reported_address); | |
c34b1796 | 41 | let actual_address = &pt as *const Point as usize; |
1a4d82fc JJ |
42 | assert_eq!(intrinsic_reported_address, actual_address); |
43 | } |