]> git.lizzy.rs Git - rust.git/blob - tests/ui/issues/issue-13259-windows-tcb-trash.rs
Rollup merge of #106427 - mejrs:translation_errors, r=davidtwco
[rust.git] / tests / ui / issues / issue-13259-windows-tcb-trash.rs
1 // run-pass
2 #![feature(rustc_private)]
3
4 extern crate libc;
5
6 #[cfg(windows)]
7 mod imp {
8     type LPVOID = *mut u8;
9     type DWORD = u32;
10     type LPWSTR = *mut u16;
11
12     extern "system" {
13         fn FormatMessageW(flags: DWORD,
14                           lpSrc: LPVOID,
15                           msgId: DWORD,
16                           langId: DWORD,
17                           buf: LPWSTR,
18                           nsize: DWORD,
19                           args: *const u8)
20                           -> DWORD;
21     }
22
23     pub fn test() {
24         let mut buf: [u16; 50] = [0; 50];
25         let ret = unsafe {
26             FormatMessageW(0x1000, core::ptr::null_mut(), 1, 0x400,
27                            buf.as_mut_ptr(), buf.len() as u32, core::ptr::null())
28         };
29         // On some 32-bit Windowses (Win7-8 at least) this will panic with segmented
30         // stacks taking control of pvArbitrary
31         assert!(ret != 0);
32     }
33 }
34
35 #[cfg(not(windows))]
36 mod imp {
37     pub fn test() { }
38 }
39
40 fn main() {
41     imp::test()
42 }