test: Enable an assert in run-pass/rec-align-32-bit.rs
This commit is contained in:
parent
e4277472d2
commit
09624a676a
1 changed files with 12 additions and 12 deletions
|
@ -2,6 +2,12 @@
|
||||||
// xfail-win32
|
// xfail-win32
|
||||||
// Issue #2303
|
// Issue #2303
|
||||||
|
|
||||||
|
#[abi = "rust-intrinsic"]
|
||||||
|
native mod rusti {
|
||||||
|
fn pref_align_of<T>() -> uint;
|
||||||
|
fn min_align_of<T>() -> uint;
|
||||||
|
}
|
||||||
|
|
||||||
// This is the type with the questionable alignment
|
// This is the type with the questionable alignment
|
||||||
type inner = {
|
type inner = {
|
||||||
c64: u64
|
c64: u64
|
||||||
|
@ -22,24 +28,18 @@ fn main() {
|
||||||
// Send it through the shape code
|
// Send it through the shape code
|
||||||
let y = #fmt["%?", x];
|
let y = #fmt["%?", x];
|
||||||
|
|
||||||
#debug("align inner = %?", sys::pref_align_of::<inner>()); // 8
|
#debug("align inner = %?", rusti::min_align_of::<inner>());
|
||||||
#debug("size outer = %?", sys::size_of::<outer>()); // 12
|
#debug("size outer = %?", sys::size_of::<outer>());
|
||||||
#debug("y = %s", y); // (22, (0))
|
#debug("y = %s", y);
|
||||||
|
|
||||||
// per clang/gcc the alignment of `inner` is 4 on x86.
|
// per clang/gcc the alignment of `inner` is 4 on x86.
|
||||||
// we say it's 8
|
assert rusti::min_align_of::<inner>() == 4u;
|
||||||
//assert sys::align_of::<inner>() == 4u; // fails
|
|
||||||
|
|
||||||
// per clang/gcc the size of `outer` should be 12
|
// per clang/gcc the size of `outer` should be 12
|
||||||
// because `inner`s alignment was 4.
|
// because `inner`s alignment was 4.
|
||||||
// LLVM packs the struct the way clang likes, despite
|
assert sys::size_of::<outer>() == 12u;
|
||||||
// our intents regarding the alignment of `inner` and
|
|
||||||
// we end up with the same size `outer` as clang
|
|
||||||
assert sys::size_of::<outer>() == 12u; // passes
|
|
||||||
|
|
||||||
// But now our shape code doesn't find the inner struct
|
assert y == "(22, (44))";
|
||||||
// We print (22, (0))
|
|
||||||
assert y == "(22, (44))"; // fails
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
|
Loading…
Reference in a new issue