[Mono-bugs] [Bug 77756][Maj] New - [GMCS] wrong code generation
when using anonymous methods
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Fri Mar 10 11:21:26 EST 2006
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by flipper98 at gmx.net.
http://bugzilla.ximian.com/show_bug.cgi?id=77756
--- shadow/77756 2006-03-10 11:21:26.000000000 -0500
+++ shadow/77756.tmp.30683 2006-03-10 11:21:26.000000000 -0500
@@ -0,0 +1,116 @@
+Bug#: 77756
+Product: Mono: Compilers
+Version: 1.1
+OS: other
+OS Details: fedora core 4
+Status: NEW
+Resolution:
+Severity:
+Priority: Major
+Component: C#
+AssignedTo: rharinath at novell.com
+ReportedBy: flipper98 at gmx.net
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: [GMCS] wrong code generation when using anonymous methods
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+gmcs generates wrong code in certain scenarios where anonymous methods are
+involved.
+
+Steps to reproduce the problem:
+compile the attached example code.
+
+Actual Results:
+bad code
+(program crashes)
+
+Expected Results:
+good code :D
+
+How often does this happen?
+always
+
+Additional Information:
+
+this is the code you should gmcs fed with:
+
+using System;
+
+namespace ConsoleApplication1
+{
+ class Program
+ {
+
+ static void Main(string[] args)
+ {
+ Program p = new Program();
+ p.f(false);
+ }
+
+ public void f(bool anyCondition)
+ {
+ if (anyCondition)
+ {
+ new MethodInvoker(
+ delegate
+ {
+ Console.WriteLine("anonymous code");
+ }).BeginInvoke(null, null);
+
+ return;
+ }
+
+ O o = new O("1", "2", "3");
+
+ new MethodInvoker(
+ delegate
+ {
+ Console.WriteLine(o.AnyMethod());
+ }).BeginInvoke(null, null);
+
+ }
+
+ private delegate void MethodInvoker();
+
+ private class O
+ {
+ public O(params string[] args)
+ {
+ // ...
+ }
+
+ public string AnyMethod()
+ {
+ return "";
+ }
+ }
+ }
+}
+
+this is the code of function f() actually produced by gmcs (decompiled with
+reflector):
+
+public void f(bool anyCondition)
+{
+ Program.<>AnonHelp<0> p<>1;
+ if (anyCondition)
+ {
+ p<>1 = new Program.<>AnonHelp<0>(); // <-- NOOO, dear gmcs,
+thats the wrong place! ;)
+ new
+Program.MethodInvoker(p<>1.<#AnonymousMethod>0).BeginInvoke(null, null);
+ }
+ else
+ {
+ string[] textArray1 = new string[] { "1", "2", "3" };
+ p<>1.<0:o> = new Program.O(textArray1);
+ new
+Program.MethodInvoker(p<>1.<#AnonymousMethod>1).BeginInvoke(null, null);
+ }
+}
More information about the mono-bugs
mailing list