I think I've spotted it. initobj
does not leave the newly initialized object on the evaluation stack - whereas newobj
does. So the stacks are unbalanced when IL_0028
is reached - if we've gone the newobj
route, then we have two items on the stack (FooData
and Nullable<int>
). If we've gone the initobj
route, then all we have is the FooData
object reference on the stack. You need to reload local 1
:
IL_0022: initobj valuetype [System.Runtime]System.Nullable`1<int32>
ldloc.1
IL_0028: nop