Skip to content

.NET 10 RC1 - System.EntryPointNotFoundException with enumerator created by Cast<T> #120270

@gbtec-georgs

Description

@gbtec-georgs

Description

The following code snippet consequently fails with System.EntryPointNotFoundException if executed using configuration Release:

while (true)
{
    var values = new[] { DayOfWeek.Saturday }.Cast<int>();
    foreach (var value in values) 
    {
    }
}

Reproduction Steps

while (true)
{
    var values = new[] { DayOfWeek.Saturday }.Cast<int>();
    foreach (var value in values) 
    {
    }
}

save this 👆 into a file and run it using dotnet run --configuration release .

Expected behavior

The code snippet runs forever without an exception.

Actual behavior

After 5000 iterations of the while loop the following exception is thrown:

Unhandled exception. System.EntryPointNotFoundException: Entry point was not found.
   at System.Collections.Generic.IEnumerator`1.get_Current()
   at Program.<Main>$(String[] args) in C:\projects\scratch\enum10\Program.cs:line 4

Regression?

It works with TFM net8.0.
It works with TFM net9.0.

Known Workarounds

Not using Cast<int> solves the problem.

Configuration

  • .NET 10.0.100-rc.1.25451.107
  • OS Windows 11
  • x64
  • the problem occurs only with configuration Release

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions