Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler doesnt create field in StateMachine in release mode #66829

Closed
GazziFX opened this issue Feb 12, 2023 · 2 comments · Fixed by #66915
Closed

Compiler doesnt create field in StateMachine in release mode #66829

GazziFX opened this issue Feb 12, 2023 · 2 comments · Fixed by #66915
Assignees
Milestone

Comments

@GazziFX
Copy link

GazziFX commented Feb 12, 2023

Version Used: dotnet 6.0.308

Steps to Reproduce:

  1. Write code below
  2. Run in debug
  3. Run in release

It happens if pointers is used

long x = 10;

unsafe
{
    Console.WriteLine(*&x);
}

await Task.Delay(1000);

unsafe
{
    Console.WriteLine(*&x);
}

Expected Behavior: prints 10 both times

Actual Behavior: prints 10 and 0

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 12, 2023
@GazziFX
Copy link
Author

GazziFX commented Feb 12, 2023

If I assign same variable it works as expected

long x = 10;

unsafe
{
    Console.WriteLine(*&x);
}

await Task.Delay(1000);

x = x;

unsafe
{
    Console.WriteLine(*&x);
}

@jaredpar jaredpar added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 14, 2023
@jaredpar jaredpar added this to the 17.6 milestone Feb 14, 2023
@jaredpar
Copy link
Member

I suspect that we're not treating & as read operations in our lifting logic here and that is what causes this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants