2
2
// xfail-win32
3
3
// Issue #2303
4
4
5
+ #[ abi = "rust-intrinsic" ]
6
+ native mod rusti {
7
+ fn pref_align_of < T > ( ) -> uint ;
8
+ fn min_align_of < T > ( ) -> uint ;
9
+ }
10
+
5
11
// This is the type with the questionable alignment
6
12
type inner = {
7
13
c64 : u64
@@ -22,24 +28,18 @@ fn main() {
22
28
// Send it through the shape code
23
29
let y = #fmt[ "%?" , x] ;
24
30
25
- #debug ( "align inner = %?" , sys :: pref_align_of :: < inner > ( ) ) ; // 8
26
- #debug ( "size outer = %?" , sys:: size_of :: < outer > ( ) ) ; // 12
27
- #debug ( "y = %s" , y) ; // (22, (0))
31
+ #debug ( "align inner = %?" , rusti :: min_align_of :: < inner > ( ) ) ;
32
+ #debug ( "size outer = %?" , sys:: size_of :: < outer > ( ) ) ;
33
+ #debug ( "y = %s" , y) ;
28
34
29
35
// per clang/gcc the alignment of `inner` is 4 on x86.
30
- // we say it's 8
31
- //assert sys::align_of::<inner>() == 4u; // fails
36
+ assert rusti:: min_align_of :: < inner > ( ) == 4 u;
32
37
33
38
// per clang/gcc the size of `outer` should be 12
34
39
// because `inner`s alignment was 4.
35
- // LLVM packs the struct the way clang likes, despite
36
- // our intents regarding the alignment of `inner` and
37
- // we end up with the same size `outer` as clang
38
- assert sys:: size_of :: < outer > ( ) == 12 u; // passes
39
-
40
- // But now our shape code doesn't find the inner struct
41
- // We print (22, (0))
42
- assert y == "(22, (44))" ; // fails
40
+ assert sys:: size_of :: < outer > ( ) == 12 u;
41
+
42
+ assert y == "(22, (44))" ;
43
43
}
44
44
45
45
#[ cfg( target_arch = "x86_64" ) ]
0 commit comments