File tree 2 files changed +25
-0
lines changed
compiler/rustc_mir_transform/src
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ pub struct CheckAlignment;
15
15
16
16
impl < ' tcx > MirPass < ' tcx > for CheckAlignment {
17
17
fn is_enabled ( & self , sess : & Session ) -> bool {
18
+ // FIXME(#112480) MSVC and rustc disagree on minimum stack alignment on x86 Windows
19
+ if sess. target . llvm_target == "i686-pc-windows-msvc" {
20
+ return false ;
21
+ }
18
22
sess. opts . debug_assertions
19
23
}
20
24
Original file line number Diff line number Diff line change
1
+ // run-pass
2
+ // only-i686-pc-windows-msvc
3
+ // compile-flags: -Copt-level=0 -Cdebug-assertions=yes
4
+
5
+ // MSVC isn't sure if on 32-bit Windows its u64 type is 8-byte-aligned or 4-byte-aligned.
6
+ // So this test ensures that on i686-pc-windows-msvc, we do not insert a runtime check
7
+ // that will fail on dereferencing of a pointer to u64 which is not 8-byte-aligned but is
8
+ // 4-byte-aligned.
9
+
10
+ #![ feature( strict_provenance) ]
11
+
12
+ fn main ( ) {
13
+ let mut x = [ 0u64 ; 2 ] ;
14
+ let ptr: * mut u8 = x. as_mut_ptr ( ) . cast :: < u8 > ( ) ;
15
+ unsafe {
16
+ let misaligned = ptr. add ( 4 ) . cast :: < u64 > ( ) ;
17
+ assert ! ( misaligned. addr( ) % 8 != 0 ) ;
18
+ assert ! ( misaligned. addr( ) % 4 == 0 ) ;
19
+ * misaligned = 42 ;
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments