Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ub-int-array test for big-endian platforms #115167

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions tests/ui/consts/const-eval/ub-int-array.64bit.stderr

This file was deleted.

8 changes: 6 additions & 2 deletions tests/ui/consts/const-eval/ub-int-array.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// stderr-per-bitwidth
//! Test the "array of int" fast path in validity checking, and in particular whether it
//! points at the right array element.

Expand All @@ -19,7 +18,12 @@ impl<T: Copy> MaybeUninit<T> {
const UNINIT_INT_0: [u32; 3] = unsafe {
//~^ ERROR it is undefined behavior to use this value
//~| invalid value at [0]
mem::transmute([MaybeUninit { uninit: () }, MaybeUninit::new(1), MaybeUninit::new(2)])
mem::transmute([
MaybeUninit { uninit: () },
// Constants chosen to achieve endianness-independent hex dump.
MaybeUninit::new(0x11111111),
MaybeUninit::new(0x22222222),
])
};
const UNINIT_INT_1: [u32; 3] = unsafe {
//~^ ERROR it is undefined behavior to use this value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-int-array.rs:19:1
--> $DIR/ub-int-array.rs:18:1
|
LL | const UNINIT_INT_0: [u32; 3] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized memory, but expected an integer
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 12, align: 4) {
__ __ __ __ 01 00 00 00 02 00 00 00 │ ░░░░........
__ __ __ __ 11 11 11 11 22 22 22 22 │ ░░░░....""""
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-int-array.rs:24:1
--> $DIR/ub-int-array.rs:28:1
|
LL | const UNINIT_INT_1: [u32; 3] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer
Expand All @@ -21,7 +21,7 @@ LL | const UNINIT_INT_1: [u32; 3] = unsafe {
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-int-array.rs:42:1
--> $DIR/ub-int-array.rs:46:1
|
LL | const UNINIT_INT_2: [u32; 3] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer
Expand Down