[Mono-dev] Compiler bug in foreach

Robert Jordan robertj at gmx.net
Fri May 28 21:11:56 EDT 2010


On 29.05.2010 01:44, Mehrdad Reshadi wrote:
> I found the following bug, wondering if others have seen this, or anything
> is being done to solve it. "foreach" is too common to have such a bug!

>          public static void Main(string[] args)
>          {
>              var o = new Y();
>              foreach (var c in new A[3] { new A(), new B(), new C() })
>                  c.f(o);
>              new B().f(o);
>          }

"foreach" is obviously not the culprit, because the issue can
be reproduced with an unrolled loop:

         public static void Main(string[] args)
         {
             var o = new Y();
             var a = new A[3] { new A(), new B(), new C() };
	    a[0].f(o);
	    a[1].f(o);
	    a[2].f(o);	
             new B().f(o);
         }

Please visit http://mono-project.com/Bugs and file a bug.

Robert



More information about the Mono-devel-list mailing list