Skip to content

Mono: Min/MinNumber lowering does not preserve the sign of zero #131130

Closed

Description

@tannergooding

Description

Mono (observed on the LLVM AOT configuration) does not preserve the sign of zero when lowering Min / MinNumber for floating-point types. Per the BCL contract, double.Min(+0.0, -0.0) (and the float/MinNumber variants) must return -0.0, treating -0.0 as less than +0.0. Mono instead returns +0.0.

Reproduction

using System;
using System.Runtime.CompilerServices;

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
static double MinNegZeroConst(double value) => double.Min(value, -0.0);

// Expected: -9223372036854775808 (bits of -0.0)
// Mono LLVM AOT actual: 0 (bits of +0.0)
Console.WriteLine(BitConverter.DoubleToInt64Bits(MinNegZeroConst(+0.0)));

The same divergence affects float.Min, double.MinNumber, and float.MinNumber.

Analysis

This surfaced in the CI for #130832: the regression test Runtime_130831 (added to validate a CoreCLR JIT constant-folding fix) fails on the AllSubsets_Mono_LLVMAot_RuntimeTests leg with:

Expected: -9223372036854775808
Actual:   0

The test has been marked [SkipOnMono] referencing this issue so it continues to validate the CoreCLR fix while the Mono divergence is tracked here.

Configuration

  • Mono, LLVM AOT (AllSubsets_Mono_LLVMAot_RuntimeTests), linux-x64 Release.

Note

This issue was authored with the assistance of GitHub Copilot.

Activity

  1. added
    untriaged
    on Jul 21, 2026
  2. dotnet-policy-service commented on Jul 21, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @steveisok, @vitek-karas
    See info in area-owners.md if you want to be subscribed.

  3. vitek-karas commented on Jul 21, 2026

    @vitek-karas
    Member

    This reproes on .NET 10 as well. Since it's a long standing issue I would vote for closing it. @steveisok what do you think?

  4. steveisok commented on Jul 21, 2026

    @steveisok
    Member

    Fine by me

  5. removed
    untriaged
    on Jul 21, 2026
  6. tannergooding commented on Jul 21, 2026

    @tannergooding
    MemberAuthor

    @vitek-karas, just noting this is a correctness and IEEE 754 compliance bug. I'm fine with not fixing it, but did want to call that out.

  7. vitek-karas commented on Jul 21, 2026

    @vitek-karas
    Member

    @tannergooding I do understand... and I don't have a problem if we get a PR to accept it...

  8. tannergooding commented on Jul 21, 2026

    @tannergooding
    MemberAuthor

    @vitek-karas, I have such a PR here: #131172

  9. added
    untriaged
    on Jul 21, 2026
  10. added a commit that references this issue on Jul 23, 2026
    ad46406
  11. removed
    untriaged
    on Jul 23, 2026
  12. locked and limited conversation to collaborators on Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions