Why the compiler emits box instructions to compare instances of a reference type?
Here is a simple generic type with a unique generic parameter constrained to reference types: class A<T> where T : class { public bool F(T r1, T r2) { return r1 == r2; } } The generated IL by csc.exe is : ldarg.1 box !T ldarg.2 box !T ceq So each parameter is boxed before proceeding with the comparison. But if the constraint indicates that "T" should never be a value type, why is the compiler trying to box r1 and r2 ? It's required to satisfy the verifiability constraints for the generated IL. Note that unverifiable doesn't necessarily mean incorrect . It works just fine without the box