Skip to content

Compilation error with latest Roslyn #865

@filipnavara

Description

@filipnavara

The following code no longer compiles:

private static int CountDefault(T[] arr)
{
int count = 0;
foreach (T item in arr)
{
if (item == default) count++;
}
return count;
}

Compiler reports the following error:

corefx/System.Buffers/ArrayPoolTests.cs(44,21): error CS0019: Operator '==' cannot be applied to operands of type 'T' and 'default' [/Users/filipnavara/agent/_work/1/s/work/performance/src/benchmarks/micro/MicroBenchmarks.csproj]

This is caused by breaking change in the compiler (dotnet/roslyn#36492) that was previously leading to miscompiled code. Originally reported as dotnet/roslyn#38568, moving here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions