-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed as duplicate of#118782
Closed as duplicate of#118782
Copy link
Labels
Description
Description
A struct containing a static [InlineArray] of itself always crashes at runtime.
Reproduction Steps
In a new console project, paste this code.
using System;
using System.Runtime.CompilerServices;
Hello a;
[InlineArray(1)]
struct HelloBuffer
{
Hello _v;
}
struct Hello
{
static HelloBuffer s_buffer;
int _v;
}Expected behavior
Should compile and run, without producing any output.
Actual behavior
Compiles, but crashes at runtime.
Unhandled exception. System.TypeLoadException: Could not load type 'Hello' from assembly 'a, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
at Program.<Main>$(String[] args)
Regression?
No response
Known Workarounds
Just place the buffer in a separate class.
using System;
using System.Runtime.CompilerServices;
Hello a;
[InlineArray(1)]
struct HelloBuffer
{
Hello _v;
}
static class HelloBufferHelper
{
static HelloBuffer s_buffer;
}
struct Hello
{
int _v;
}Configuration
.NET 9.0.203
Linux 6.15.9-106.bazzite.fc42.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Aug 9 13:06:19 UTC 2025 x86_64 GNU/Linux
I haven't tested on different platforms, architectures, .NET versions, and configurations.
Other information
No response