Skip to content

JIT: (bug) a dominating branch makes a later if on an unrelated bool return the wrong answer #133558

Closed

Description

@EgorBo

Repro

using System;
using System.Runtime.CompilerServices;

internal static class Program
{
    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
    private static int Test(int a, int b)
    {
        bool c = a != b;
        if (a > b)
            goto Shared;
        if (c)
            return 1;
    Shared:
        return 0;
    }

    private static void Main()
    {
        Console.WriteLine(Test(3, 5));
    }
}

Expected

1

Actual

0

a = 3, b = 5, so a > b is false and c is true, but Test is compiled to an
unconditional return 0.

Platform

Windows x64, local Checked build of dotnet/runtime main (ef97eb5).

Activity

  1. added this to the 12.0.0 milestone on Sep 10, 2026
  2. added
    area-CodeGen-coreclr
    on Sep 10, 2026
  3. dotnet-policy-service commented on Sep 10, 2026

    @dotnet-policy-service
    Contributor

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

  4. MihuBot commented on Sep 10, 2026

    @MihuBot

    I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):

  5. self-assigned this
    on Sep 10, 2026
  6. added a commit that references this issue on Sep 11, 2026
    217339b
  7. EgorBo commented on Sep 18, 2026

    @EgorBo
    MemberAuthor

    Affected SDK versions:

    • 11.0.100-rc.2.26467.112
  8. EgorBo commented on Sep 18, 2026

    @EgorBo
    MemberAuthor

    @AndyAyersMS would you consider backporting the fix from #133621 to release/11.0?

    It currently only exists in main (12.0). The repro still fails on the shipped 11.0 RC2 SDK (11.0.100-rc.2.26467.112), while 8.0.425, 9.0.318 and 10.0.401 all behave correctly, so this is a regression introduced during the 11.0 cycle rather than a long-standing bug — 11.0 would ship with it.

    Note: this comment was produced by an AI agent; the repro was re-run against all four released SDKs to confirm the results above.

  9. locked and limited conversation to collaborators on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions