Skip to content

[riscv64] tests/ui/float/minmax.rs: assertion left == right failed #156529

Closed

Description

@yuzibo

Detected by Ruyici:

---- [ui] tests/ui/float/minmax.rs stdout ----

error: test did not exit with success! code=Some(101) so test would pass with `run-fail`
status: exit status: 101
command: cd "/home/jenkins/rust/build/riscv64gc-unknown-linux-gnu/test/ui/float/minmax" && RUSTC="/home/jenkins/rust/build/riscv64gc-unknown-linux-gnu/stage2/bin/rustc" RUST_TEST_THREADS="64" "/home/jenkins/rust/build/riscv64gc-unknown-linux-gnu/test/ui/float/minmax/a"
stdout: none
--- stderr -------------------------------

thread 'main' (180512) panicked at /home/jenkins/rust/tests/ui/float/minmax.rs:14:5:
assertion `left == right` failed
  left: NaN
 right: -9.0
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<f32, f32>
   4: minmax::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
------------------------------------------

---- [ui] tests/ui/float/minmax.rs stdout end ----

Opening it to track this.

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 13, 2026
  2. yuzibo commented on May 13, 2026

    @yuzibo
    ContributorAuthor

    @rustbot label +O-riscv

  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 13, 2026
  4. folkertdev commented on May 13, 2026

    @folkertdev
    Contributor

    That means min is implemented incorrectly on riscv, though it looks like LLVM main already fixes this https://godbolt.org/z/M8sqhf58s. Perhaps you can get that cherry-picked onto the LLVM 22 branch?

  5. added
    llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixes
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    on May 13, 2026
  6. SpriteOvO commented on May 13, 2026

    @SpriteOvO
    Member

    Since #153343, Rust intrinsic minnum will be lowered to llvm.minimumnum instead of llvm.minnum, because llvm.minnum non-deterministically returns either NaN or the other value, and the intrinsic has also renamed.

    @folkertdev You used llvm.minnum in the example, so the observed difference may not be entirely unexpected, and if you remove -mtriple option, you'll see the same difference on x86 as well.

    I suspect this is a RISC-V hardware implementation bug, considering that there have been known reports of defects about floating-point in certain RISC-V hardware, and also RISC-V ISA previously modified the definitions of fmin and fmax instructions in riscv/riscv-isa-manual#75 -- before ISA v2.2 they implement IEEE 754-2008 minNum and maxNum, since ISA v2.2 they implement IEEE 754-2019 minimumNumber and maximumNumber.

  7. added
    C-defective-hardwareCategory: Issue that was filed as a possible software bug but is actually defective hardware
    and removed
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixes
    on May 13, 2026
  8. yuzibo commented on May 14, 2026

    @yuzibo
    ContributorAuthor

    Since #153343, Rust intrinsic minnum will be lowered to llvm.minimumnum instead of llvm.minnum, because llvm.minnum non-deterministically returns either NaN or the other value, and the intrinsic has also renamed.

    @folkertdev You used llvm.minnum in the example, so the observed difference may not be entirely unexpected, and if you remove -mtriple option, you'll see the same difference on x86 as well.

    I suspect this is a RISC-V hardware implementation bug, considering that there have been known reports of defects about floating-point in certain RISC-V hardware, and also RISC-V ISA previously modified the definitions of fmin and fmax instructions in riscv/riscv-isa-manual#75 -- before ISA v2.2 they implement IEEE 754-2008 minNum and maxNum, since ISA v2.2 they implement IEEE 754-2019 minimumNumber and maximumNumber.

    Thanks for the excellent explanations. I confirm this bug is a false positive. I did not reproduce this on another riscv64 hardware.

    So close this. Thanks for everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-floating-pointArea: Floating point numbers and arithmeticC-bugCategory: This is a bug.C-defective-hardwareCategory: Issue that was filed as a possible software bug but is actually defective hardwareO-riscvTarget: RISC-V architecture

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions