make shim_arg_size ptr-width-independent

This commit is contained in:
Ralf Jung 2022-08-31 16:05:40 +02:00
parent 671a4b8b0f
commit 1135ad31ab
3 changed files with 7 additions and 29 deletions

View File

@ -1,15 +0,0 @@
error: Undefined Behavior: scalar size mismatch: expected 8 bytes but got 4 bytes instead
--> $DIR/shim_arg_size.rs:LL:CC
|
LL | let _p1 = malloc(42);
| ^^^^^^^^^^ scalar size mismatch: expected 8 bytes but got 4 bytes instead
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at $DIR/shim_arg_size.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to previous error

View File

@ -1,17 +1,10 @@
//@stderr-per-bitwidth
fn main() {
extern "C" {
// Use the wrong type(ie. not the pointer width) for the `size`
// argument.
#[cfg(target_pointer_width = "64")]
fn malloc(size: u32) -> *mut std::ffi::c_void;
#[cfg(target_pointer_width = "32")]
fn malloc(size: u16) -> *mut std::ffi::c_void;
// Use the wrong type (ie. not `i32`) for the `c` argument.
fn memchr(s: *const std::ffi::c_void, c: u8, n: usize) -> *mut std::ffi::c_void;
}
unsafe {
let _p1 = malloc(42); //~ ERROR: Undefined Behavior: scalar size mismatch
memchr(std::ptr::null(), 0, 0); //~ ERROR: Undefined Behavior: scalar size mismatch
};
}

View File

@ -1,12 +1,12 @@
error: Undefined Behavior: scalar size mismatch: expected 4 bytes but got 2 bytes instead
error: Undefined Behavior: scalar size mismatch: expected 4 bytes but got 1 bytes instead
--> $DIR/shim_arg_size.rs:LL:CC
|
LL | let _p1 = malloc(42);
| ^^^^^^^^^^ scalar size mismatch: expected 4 bytes but got 2 bytes instead
LL | memchr(std::ptr::null(), 0, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ scalar size mismatch: expected 4 bytes but got 1 bytes instead
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: backtrace:
= note: BACKTRACE:
= note: inside `main` at $DIR/shim_arg_size.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace