Skip to content

Constant folding for long->float produces an incorrect result. #90323

Description

@tannergooding

Consider the following program:

using System;
using System.Runtime.CompilerServices;

long l = 0x4000_0040_0000_0001L;
Console.WriteLine((float)l);
    
Test1(l);
Test2(l);

[MethodImpl(MethodImplOptions.NoInlining)]
static void Test1(long l) => Console.WriteLine((float)l);

[MethodImpl(MethodImplOptions.NoInlining)]
static void Test2(long l) => Console.WriteLine((float)(double)l);

The expected result is:

4.6116866E+18
4.6116866E+18
4.611686E+18

The actual result is:

4.611686E+18
4.6116866E+18
4.611686E+18

Activity

  1. ghost added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Aug 10, 2023
  2. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Aug 10, 2023
  3. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Aug 10, 2023
  4. added this to the 8.0.0 milestone on Aug 10, 2023
  5. removed
    untriagedNew issue has not been triaged by the area owner
    on Aug 10, 2023
  6. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Aug 14, 2023
  7. ghost locked as resolved and limited conversation to collaborators on Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions