I was not able to find any updated or additional guidance in the updated spec apart from what TheGeneral posted here.
Starting at 18.7 Fixed size buffers and continuing further
There are several references, the most notable
Fixed size buffers are not subject to definite assignment checking
(§5.3), and fixed size buffer members are ignored for purposes of
definite assignment checking of struct type variables. When the
outermost containing struct variable of a fixed size buffer member is
a static variable, an instance variable of a class instance, or an
array element, the elements of the fixed size buffer are automatically
initialized to their default values (§5.2). In all other cases, the
initial content of a fixed size buffer is undefined.
That said, I can confirm there is at least one situation--in .NET 6--in which the data in a fixed sized buffer may not be initialized. I just ran into this, and in my case, my struct was stored in a variable declared and new-ed within a for loop. On the first iteration, the struct's inner fixed sized buffer was clear as expected; however, each additional newing on subsequent iterations did absolutely nothing, so data accumulated, and several of my tests failed.
I found two ways to get the tests passing:
- Add a
Clear method to my struct, and either call it after every new or add it to the struct's parameterless constructor.
- Delete the parameterless constructor from my struct, the existance of which was apparently preventing the buffer from being cleared.
I would pay close attention when the spec says something is undefined, and do not take chances. If you want the data to be clear, you should be sure to clear it yourself. Otherwise, you can never be certain that your code will work in every situation or that its behavior will not change significantly after an update.