Skip to content

Commit c1a3472

Browse files
committed
organize failing ABI compat tests and add some more
1 parent 1e95aa0 commit c1a3472

14 files changed

+58
-10
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
fn f(_: f32) {}
3+
4+
let g = unsafe { std::mem::transmute::<fn(f32), fn(i32)>(f) };
5+
6+
g(42) //~ ERROR: calling a function with argument of type f32 passing data of type i32
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: calling a function with argument of type f32 passing data of type i32
2+
--> $DIR/abi_mismatch_int_vs_float.rs:LL:CC
3+
|
4+
LL | g(42)
5+
| ^^^^^ calling a function with argument of type f32 passing data of type i32
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at $DIR/abi_mismatch_int_vs_float.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to previous error
15+

src/tools/miri/tests/fail/function_pointers/cast_fn_ptr4.stderr renamed to src/tools/miri/tests/fail/function_pointers/abi_mismatch_raw_pointer.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: Undefined Behavior: calling a function with argument of type *const [i32] passing data of type *const i32
2-
--> $DIR/cast_fn_ptr4.rs:LL:CC
2+
--> $DIR/abi_mismatch_raw_pointer.rs:LL:CC
33
|
44
LL | g(&42 as *const i32)
55
| ^^^^^^^^^^^^^^^^^^^^ calling a function with argument of type *const [i32] passing data of type *const i32
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: BACKTRACE:
10-
= note: inside `main` at $DIR/cast_fn_ptr4.rs:LL:CC
10+
= note: inside `main` at $DIR/abi_mismatch_raw_pointer.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1313

src/tools/miri/tests/fail/function_pointers/cast_fn_ptr5.stderr renamed to src/tools/miri/tests/fail/function_pointers/abi_mismatch_return_type.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: Undefined Behavior: calling a function with return type u32 passing return place of type ()
2-
--> $DIR/cast_fn_ptr5.rs:LL:CC
2+
--> $DIR/abi_mismatch_return_type.rs:LL:CC
33
|
44
LL | g()
55
| ^^^ calling a function with return type u32 passing return place of type ()
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: BACKTRACE:
10-
= note: inside `main` at $DIR/cast_fn_ptr5.rs:LL:CC
10+
= note: inside `main` at $DIR/abi_mismatch_return_type.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1313

src/tools/miri/tests/fail/function_pointers/cast_fn_ptr2.stderr renamed to src/tools/miri/tests/fail/function_pointers/abi_mismatch_simple.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: Undefined Behavior: calling a function with argument of type (i32, i32) passing data of type i32
2-
--> $DIR/cast_fn_ptr2.rs:LL:CC
2+
--> $DIR/abi_mismatch_simple.rs:LL:CC
33
|
44
LL | g(42)
55
| ^^^^^ calling a function with argument of type (i32, i32) passing data of type i32
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: BACKTRACE:
10-
= note: inside `main` at $DIR/cast_fn_ptr2.rs:LL:CC
10+
= note: inside `main` at $DIR/abi_mismatch_simple.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1313

src/tools/miri/tests/fail/function_pointers/cast_fn_ptr3.stderr renamed to src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_few_args.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: Undefined Behavior: calling a function with fewer arguments than it requires
2-
--> $DIR/cast_fn_ptr3.rs:LL:CC
2+
--> $DIR/abi_mismatch_too_few_args.rs:LL:CC
33
|
44
LL | g()
55
| ^^^ calling a function with fewer arguments than it requires
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: BACKTRACE:
10-
= note: inside `main` at $DIR/cast_fn_ptr3.rs:LL:CC
10+
= note: inside `main` at $DIR/abi_mismatch_too_few_args.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1313

src/tools/miri/tests/fail/function_pointers/cast_fn_ptr1.stderr renamed to src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_many_args.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: Undefined Behavior: calling a function with more arguments than it expected
2-
--> $DIR/cast_fn_ptr1.rs:LL:CC
2+
--> $DIR/abi_mismatch_too_many_args.rs:LL:CC
33
|
44
LL | g(42)
55
| ^^^^^ calling a function with more arguments than it expected
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: BACKTRACE:
10-
= note: inside `main` at $DIR/cast_fn_ptr1.rs:LL:CC
10+
= note: inside `main` at $DIR/abi_mismatch_too_many_args.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1313

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(portable_simd)]
2+
use std::simd;
3+
4+
fn main() {
5+
fn f(_: simd::u32x8) {}
6+
7+
// These two vector types have the same size but are still not compatible.
8+
let g = unsafe { std::mem::transmute::<fn(simd::u32x8), fn(simd::u64x4)>(f) };
9+
10+
g(Default::default()) //~ ERROR: calling a function with argument of type std::simd::Simd<u32, 8> passing data of type std::simd::Simd<u64, 4>
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: calling a function with argument of type std::simd::Simd<u32, 8> passing data of type std::simd::Simd<u64, 4>
2+
--> $DIR/abi_mismatch_vector.rs:LL:CC
3+
|
4+
LL | g(Default::default())
5+
| ^^^^^^^^^^^^^^^^^^^^^ calling a function with argument of type std::simd::Simd<u32, 8> passing data of type std::simd::Simd<u64, 4>
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at $DIR/abi_mismatch_vector.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to previous error
15+

0 commit comments

Comments
 (0)