Bugzilla – Bug 372412
gmcs don't emit readonly prefix for generic array access.
Last modified: 2010-04-29 10:45:44 UTC
When generics code need to do load the address of an array element of generic type it must emit a readonly prefix, otherwise a System.ArrayTypeMismatchException will be raised. For example: T[] t; t[0].GetHashCode(); Must be compiled to: ldc.i4.0 readonly. ldelema !T constrained. !T callvirt instance int32 object::GetHashCode() Right now gmcs don't emit the readonly. prefix. This applies to Array::Address magic methods as well. See #372410 for a test case and the long explanation of why the readonly prefix is required.
Fixed in trunk. Is there easy test for this?