[Mono-bugs] [Bug 440819] New: Array generic interfaces are not type-safe

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Nov 1 06:41:54 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=440819


           Summary: Array generic interfaces are not type-safe
           Product: Mono: Runtime
           Version: SVN
          Platform: x86-64
        OS/Version: Linux
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: generics
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: harinath at hurrynot.org
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


The following code snippet exhibits unsafe behaviour in the implementation of
array generic interfaces.

----------8<---------
using System;
using System.Collections.Generic;

class A {
  static void Main ()
  {
    A [] aa = new A [1];
    IList<object> io = aa;
    io [0] = new object ();
    A a = aa [0];
    Console.WriteLine ("{0}", a.GetType ());
  }
}
----------8<---------

When compiled and run on mono, this emits the following

  $ ./mono-2.0 array-bad.exe 
  System.Object

The expected behaviour is to throw a ArrayTypeMismatchException.  (caveat: I
haven't actually tested it on .NET, the actual exception thrown may be
different)


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list