Skip to content

JIT: Inliner direct substitution of return buffers can reorder side effects #112053

Closed as duplicate
@jakobbotsch

Description

@jakobbotsch

The following program throws DivideByZeroException when optimizing and NullReferenceException otherwise. The correct exception is DivideByZeroException.

using System;
using System.Runtime.CompilerServices;

public unsafe class Program
{
    public static void Main()
    {
        Foo(null, 0);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static void Foo(C c, int x)
    {
        c.G = Test(1 / x);
    }

    public static Guid Test(int x)
    {
        return new Guid(x, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    class C
    {
        public Guid G;
    }
}

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions