-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
dotnet/coreclr
#26952Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbug
Milestone
Description
Environment:
•Visual Studio 2019 version 16.2.3
•.Net 4.8
•Console application
•x64 build
•Release build
Code to reproduce:
using System;
namespace Demo
{
class Program
{
static int _a;
static void Main()
{
_a = 1;
while (_a == 1)
{
Console.WriteLine(_a);
_a = 0;
}
}
}
}
Expected Behavior:
"1" is printed once and the program terminates.
Actual Behavior:
"0" is repeatedly printed; the program does not terminate.
Notes
If you declare _a as volatile, it works OK.
If you initialise _a as static int _a = 0; it works.
This was reported on StackOverflow here: https://stackoverflow.com/questions/57693386/vs-2019-optimize-code-in-release-mode-broken
category:correctness
theme:optimization
skill-level:expert
cost:large
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbug