[Mono-dev] Initialization of array of enum - trying to not use RuntimeInternals.InitializeArray

John Cronin jncronin at tysos.org
Sun Jul 22 19:11:57 UTC 2012

There is a known bug in the Microsoft CLR on the x86_64 platform with 
regards to initializing an array whose members are enum values 
It appears that the Microsoft csc compiler somehow works around this 
whereas gmcs does not.  For example, the following compiled with gmcs 
does not run on the Microsoft CLR on x86_64 (it throws an exception in 
InitializeArray) but does when compiled with csc:

class Program
   enum e { A, B, C, D, E };
   static void Main()
     e[] array = new e[] { e.A, e.B, e.C, e.D, e.E };

I appreciate this is apparently a bug with the Microsoft 64 bit CLR 
rather than mono, but at the moment Microsoft's csc appears to work 
around this where mono does not.  Is there a way of telling gmcs to not 
use a call to InitializeArray when instantiating arrays of enums 
(instead doing something like: e[] array = new e[5]; e[0] = e.A; e[1] = 
e.B; ... for the above example), or if not would there be any support 
for adding this (e.g. via an optional command line flag to gmcs)?


More information about the Mono-devel-list mailing list