Beef icon indicating copy to clipboard operation
Beef copied to clipboard

[Bug] Static append can overlay other fields in memory

Open m910q opened this issue 1 year ago • 0 comments

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;
    }
}

m910q avatar Apr 16 '24 18:04 m910q