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