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.
|
|
|
|
#[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
|
|
|
|
|
|
|
#[cfg(target_pointer_width="32")]
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|