Skip to content

Some mirunsafeck and thirunsafeck tests failing with weird assert failure #96

Closed
@antoyo

Description

@antoyo
---- [ui] ui/union/union-overwrite.rs#mirunsafeck stdout ----

error in revision `mirunsafeck`: test run failed!
status: signal: 6 (core dumped)
command: "/Projets/rustc_codegen_gccjit/rust/build/x86_64-unknown-linux-gnu/test/ui/union/union-overwrite.mirunsafeck/a"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `57022`,
 right: `57022`', /Projets/rustc_codegen_gccjit/rust/src/test/ui/union/union-overwrite.rs:34:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

That happens only when compiled in release mode, not in debug mode.

Example:

union U {
    a: (u8, u8),
    b: u16,
}

union W {
    a: u32,
    b: f32,
}

fn main() {
    unsafe {
        let mut u = U { a: (1, 1) };
        assert_eq!(u.b, (1 << 8) + 1);
        u.b = (2 << 8) + 2;
        assert_eq!(u.a, (2, 2));

        let mut w = W { a: 0b0_11111111_00000000000000000000000 };
        assert_eq!(w.b, f32::INFINITY);
        w.b = f32::NEG_INFINITY;
        assert_eq!(w.a, 0b1_11111111_00000000000000000000000);
    }
}

gives:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `(2, 2)`,
 right: `(2, 2)`', src/main.rs:16:9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions