Bug 372412 - gmcs don't emit readonly prefix for generic array access.
Summary: gmcs don't emit readonly prefix for generic array access.
Status: RESOLVED FIXED
Alias: None
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: Other Other
: P5 - None : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-19 16:14 UTC by Rodrigo Kumpera
Modified: 2010-04-29 10:45 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rodrigo Kumpera 2008-03-19 16:14:06 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.
Comment 1 Marek Safar 2010-04-29 10:45:44 UTC
Fixed in trunk. Is there easy test for this?