提交 09624a67 编写于 作者: B Brian Anderson

test: Enable an assert in run-pass/rec-align-32-bit.rs

上级 e4277472
...@@ -2,6 +2,12 @@ ...@@ -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() { ...@@ -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 y == "(22, (44))";
assert sys::size_of::<outer>() == 12u; // passes
// But now our shape code doesn't find the inner struct
// We print (22, (0))
assert y == "(22, (44))"; // fails
} }
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册