Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

ices/86193.rs: fixed with errors #825

Merged
merged 1 commit into from
Jun 14, 2021
Merged

ices/86193.rs: fixed with errors #825

merged 1 commit into from
Jun 14, 2021

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#86193

#![crate_type = "lib"]
#[repr(transparent)]
struct W<T>(T);

// The drop fn is checked before size/align are, so get ourselves a "sufficiently valid" drop fn
fn drop_me(_: *mut usize) {}

const INVALID_VTABLE_SIZE: W<&dyn Send> =
    unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) };
=== stdout ===
=== stderr ===
warning: struct is never constructed: `W`
 --> /home/runner/work/glacier/glacier/ices/86193.rs:3:8
  |
3 | struct W<T>(T);
  |        ^
  |
  = note: `#[warn(dead_code)]` on by default

warning: function is never used: `drop_me`
 --> /home/runner/work/glacier/glacier/ices/86193.rs:6:4
  |
6 | fn drop_me(_: *mut usize) {}
  |    ^^^^^^^

warning: constant is never used: `INVALID_VTABLE_SIZE`
 --> /home/runner/work/glacier/glacier/ices/86193.rs:8:1
  |
8 | / const INVALID_VTABLE_SIZE: W<&dyn Send> =
9 | |     unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) };
  | |______________________________________________________________________________________________^

error[E0080]: it is undefined behavior to use this value
 --> /home/runner/work/glacier/glacier/ices/86193.rs:8:1
  |
8 | / const INVALID_VTABLE_SIZE: W<&dyn Send> =
9 | |     unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) };
  | |______________________________________________________________________________________________^ type validation failed: encountered invalid vtable: size is bigger than largest supported object at .0
  |
  = 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: 16, align: 8) {
              ╾───────alloc3────────╼ ╾───────alloc6────────╼ │ ╾──────╼╾──────╼
          }

error: aborting due to previous error; 3 warnings emitted

For more information about this error, try `rustc --explain E0080`.
==============

=== stdout ===
=== stderr ===
warning: struct is never constructed: `W`
 --> /home/runner/work/glacier/glacier/ices/86193.rs:3:8
  |
3 | struct W<T>(T);
  |        ^
  |
  = note: `#[warn(dead_code)]` on by default

warning: function is never used: `drop_me`
 --> /home/runner/work/glacier/glacier/ices/86193.rs:6:4
  |
6 | fn drop_me(_: *mut usize) {}
  |    ^^^^^^^

warning: constant is never used: `INVALID_VTABLE_SIZE`
 --> /home/runner/work/glacier/glacier/ices/86193.rs:8:1
  |
8 | / const INVALID_VTABLE_SIZE: W<&dyn Send> =
9 | |     unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) };
  | |______________________________________________________________________________________________^

error[E0080]: it is undefined behavior to use this value
 --> /home/runner/work/glacier/glacier/ices/86193.rs:8:1
  |
8 | / const INVALID_VTABLE_SIZE: W<&dyn Send> =
9 | |     unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) };
  | |______________________________________________________________________________________________^ type validation failed: encountered invalid vtable: size is bigger than largest supported object at .0
  |
  = 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: 16, align: 8) {
              ╾───────alloc3────────╼ ╾───────alloc6────────╼ │ ╾──────╼╾──────╼
          }

error: aborting due to previous error; 3 warnings emitted

For more information about this error, try `rustc --explain E0080`.
==============
@Alexendoo Alexendoo merged commit 957ce67 into master Jun 14, 2021
@Alexendoo Alexendoo deleted the autofix/ices/86193.rs branch June 14, 2021 15:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants