2022-03-17 08:49:10 -05:00
|
|
|
// stderr-per-bitwidth
|
|
|
|
|
2020-04-26 23:05:19 -05:00
|
|
|
fn main() {
|
|
|
|
extern "C" {
|
2020-04-26 23:30:35 -05:00
|
|
|
// Use the wrong type(ie. not the pointer width) for the `size`
|
|
|
|
// argument.
|
2022-06-21 01:40:39 -05:00
|
|
|
#[cfg(target_pointer_width = "64")]
|
2020-04-26 23:05:19 -05:00
|
|
|
fn malloc(size: u32) -> *mut std::ffi::c_void;
|
2020-04-26 23:30:35 -05:00
|
|
|
|
2022-06-21 01:40:39 -05:00
|
|
|
#[cfg(target_pointer_width = "32")]
|
2020-04-26 23:30:35 -05:00
|
|
|
fn malloc(size: u16) -> *mut std::ffi::c_void;
|
2020-04-26 23:05:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe {
|
2020-04-27 05:04:42 -05:00
|
|
|
let _p1 = malloc(42); //~ ERROR Undefined Behavior: scalar size mismatch
|
2020-04-26 23:05:19 -05:00
|
|
|
};
|
|
|
|
}
|