Format | Assembly Format | Description |
---|---|---|
70 <T> | cpobj typeTok |
Copy a value type from src to dest. |
…, dest, src → …,
The cpobj
instruction copies the value at the address specified by src (an unmanaged pointer, native int
, or a managed pointer, &
) to the address specified by dest (also a pointer). typeTok can be a typedef
, typeref
, or typespec
. The behavior is unspecified if the type of the location referenced by src is not assignable-to (§I.8.7.3) the type of the location referenced by dest. If typeTok is a reference type, the cpobj
instruction has the same effect as ldind.ref
followed by stind.ref
.
System.NullReferenceException
can be thrown if an invalid address is detected.
System.TypeLoadException
is thrown if typeTok cannot be found. This is typically detected when CIL is converted to native code rather than at runtime.
typeTok shall be a valid typedef
, typeref
, or typespec
metadata token.
The tracked types of the destination (dest) and source (src) values shall both be managed pointers (&)
to values whose types we denote destType and srcType, respectively. Finally, srcType shall be assignable-to (§I.8.7.3) typeTok, and typeTok shall be assignable-to (§I.8.7.3) destType. In the case of an Enum, its type is that of the underlying, or base, type of the Enum.