Description
int x = 61 % 12 switch
{
0 => 0,
2 => 1,
4 => 2,
5 => 3,
7 => 4,
9 => 5,
11 => 6,
_ => 0,
};
This code is throwing a nonsense exception: System.DivideByZeroException: Attempted to divide by zero.
Project file is
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
No extra obscure compilation options. The problem persists on net10.
Reproduction Steps
Just run the statement in the main function on a console app.
Expected behavior
Expected behavior is x = 0, coming from the default case.
Actual behavior
Throws System.DivideByZeroException.
Regression?
No response
Known Workarounds
No response
Configuration
Ran on windows 11.
Other information
Possibly some optimization/compilation bug.
Description
This code is throwing a nonsense exception: System.DivideByZeroException: Attempted to divide by zero.
Project file is
No extra obscure compilation options. The problem persists on net10.
Reproduction Steps
Just run the statement in the main function on a console app.
Expected behavior
Expected behavior is
x = 0, coming from the default case.Actual behavior
Throws System.DivideByZeroException.
Regression?
No response
Known Workarounds
No response
Configuration
Ran on windows 11.
Other information
Possibly some optimization/compilation bug.