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

[Bug] Static append can overlay other fields in memory #1953

Open
m910q opened this issue Apr 16, 2024 · 0 comments
Open

[Bug] Static append can overlay other fields in memory #1953

m910q opened this issue Apr 16, 2024 · 0 comments

Comments

@m910q
Copy link
Contributor

m910q commented Apr 16, 2024

Creating a static append List<T> field with an initial capacity, overlays the memory for the static fields that follows.
It works fine with instance fields.

Tested in latest nightly.

using System;
using System.Collections;
namespace Playground;

class Program
{
    static append List<int> list = .(1024);
    static int value = 1;

    public static int Main(String[] args)
    {
        list.Add(2);
        System.Diagnostics.Debug.WriteLine($"{value}"); // Writes 2, expected 1
        return 0;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant