title: Why does stackalloc initialization have inconsistent behavior?
body: <p>The following code initializes two stackalloc arrays with non-zero values. While array A is properly initialized, array B remains filled with zeroes, contrary to what is expected.</p>
  
  <p>By disassembling the compiled executable, one can see that no initialization code is generated for array B. Why is that?</p>
  
  <pre><code>using System;
  
  namespace ConsoleApp1
  {
      class Program
      {
          static unsafe void Main(string[] args)
          {
              double a1 = 1;
              double* A = stackalloc double[] { a1, 0, 0, a1, a1 }; // results in 1 0 0 1 1
              double* B = stackalloc double[] { a1, 0, 0, 0, 0}; // results in 0 0 0 0 0 
  
              for (int i = 0; i &lt; 5; i++) Console.Write($"{A[i]} ");
              Console.WriteLine();
              for (int i = 0; i &lt; 5; i++) Console.Write($"{B[i]} ");
          }
      }
  }
  </code></pre>
  
  <p>Expected results:</p>
  
  <pre><code>1 0 0 1 1
  1 0 0 0 0
  </code></pre>
  
  <p>Actual results:</p>
  
  <pre><code>1 0 0 1 1
  0 0 0 0 0
  </code></pre>