title: Why the compiler emits box instructions to compare instances of a reference type?
body: <p>Here is a simple generic type with a unique generic parameter constrained to reference types:</p>
  
  <pre><code>class A&lt;T&gt; where T : class
  {
      public bool F(T r1, T r2)
      {
          return r1 == r2;
      }
  }
  </code></pre>
  
  <p>The generated <strong>IL</strong> by csc.exe is :</p>
  
  <pre><code>ldarg.1
  box        !T
  ldarg.2
  box        !T
  ceq
  </code></pre>
  
  <p>So each parameter is <strong>boxed</strong> before proceeding with the comparison.</p>
  
  <p>But if the constraint indicates that "T" should never be a value type, <strong>why is the compiler trying to box <code>r1</code> and <code>r2</code></strong> ?</p>