Skip to content

ui/unsafe/union.rs test has UB #95075

Closed
@bjorn3

Description

@bjorn3

https://github.com/rust-lang/rust/blob/691d1c1e12602c57237e9ccddac406ebd0c54082/src/test/ui/unsafe/union.rs

Running it in miri gives the following error:

error: Undefined Behavior: enum value has invalid tag: 0x07
  --> example/union.rs:49:15
   |
49 |         match foo {
   |               ^^^ enum value has invalid tag: 0x07
   |
   = 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: inside `main` at example/union.rs:49:15

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

I found this issue because cg_clif aborts matching on an invalid discriminant.

cc @Smittyvb as you introduced this test.

Metadata

Metadata

Assignees

Labels

A-craneliftThings relevant to the [future] cranelift backendC-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions