]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/tag-align-u64.rs
auto merge of #19648 : mquandalle/rust/patch-1, r=alexcrichton
[rust.git] / src / test / run-pass / tag-align-u64.rs
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
11 // ignore-linux #7340 fails on 32-bit Linux
12 // ignore-macos #7340 fails on 32-bit macos
13
14 use std::mem;
15
16 enum Tag {
17     TagInner(u64)
18 }
19
20 struct Rec {
21     c8: u8,
22     t: Tag
23 }
24
25 fn mk_rec() -> Rec {
26     return Rec { c8:0u8, t:Tag::TagInner(0u64) };
27 }
28
29 fn is_8_byte_aligned(u: &Tag) -> bool {
30     let p: uint = unsafe { mem::transmute(u) };
31     return (p & 7u) == 0u;
32 }
33
34 pub fn main() {
35     let x = mk_rec();
36     assert!(is_8_byte_aligned(&x.t));
37 }