1 //! Test casts for alignment issues
7 #[warn(cast_ptr_alignment)]
8 #[allow(no_effect, unnecessary_operation, cast_lossless)]
10 /* These should be warned against */
12 // cast to more-strictly-aligned type
13 (&1u8 as *const u8) as *const u16;
14 (&mut 1u8 as *mut u8) as *mut u16;
16 /* These should be okay */
20 // cast to less-strictly-aligned type
21 (&1u16 as *const u16) as *const u8;
22 (&mut 1u16 as *mut u16) as *mut u8;
23 // For c_void, we should trust the user. See #2677
24 (&1u32 as *const u32 as *const std::os::raw::c_void) as *const u32;
25 (&1u32 as *const u32 as *const libc::c_void) as *const u32;