[Mono-bugs] [Bug 79197][Wis] New - [GMCS] anonymous delegates which return a value are miscompiled

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Aug 28 13:34:00 EDT 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 jonpryor at vt.edu.

http://bugzilla.ximian.com/show_bug.cgi?id=79197

--- shadow/79197	2006-08-28 13:34:00.000000000 -0400
+++ shadow/79197.tmp.13058	2006-08-28 13:34:00.000000000 -0400
@@ -0,0 +1,113 @@
+Bug#: 79197
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: jonpryor at vt.edu               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [GMCS] anonymous delegates which return a value are miscompiled
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+gmcs doesn't like compiling anonymous delegates which return a value.
+
+Steps to reproduce the problem:
+1. Take the following code, saving it to `ad.cs':
+
+  // fun w/ anonymous delegates!
+  using System;
+  using System.Collections.Generic;
+  using System.Text.RegularExpressions;
+
+  class Test {
+    delegate bool CommandHandler (string line);
+
+    static Dictionary <string, CommandHandler> commands;
+    static Test ()
+    {
+      commands = new Dictionary <string, CommandHandler> ();
+      commands ["help"] = delegate (string line) {
+        Console.WriteLine ("insert help text here");
+        return true;
+      };
+    }
+
+    public static void Main ()
+    {
+      Console.WriteLine ("Welcome to the silly command interpreter.");
+      Console.WriteLine ("Supported commands: ");
+      foreach (string key in commands.Keys)
+        Console.WriteLine ("\t" + key);
+      Regex r = new Regex (@"^([\w]+)");
+      string line;
+      while ((line = Console.In.ReadLine ()) != null) {
+        Match m = r.Match (line);
+        if (m.Success) {
+          string command = m.Groups [0].Value;
+          if (commands.ContainsKey (command)) {
+            commands [command] (line);
+          }
+          else {
+            Console.WriteLine ("invalid command `{0}' in line: {1}", 
+              command, line);
+          }
+        }
+        else {
+          Console.WriteLine ("no command specified: " + line);
+        }
+      }
+    }
+  }
+
+2. Compile it:
+
+  $ gmcs ad.cs
+  ad.cs(14,9): warning CS0162: Unreachable code detected
+  Compilation succeeded - 1 warning(s)
+
+Note that gmcs gives a warning about "unreachable" code, which is
+incorrect, there is no unreachable code.
+
+3. Run it:
+
+  $ mono ad.exe
+  Welcome to the silly command interpreter.
+  Supported commands:
+        help
+
+and enter random \n-separated text:
+
+  foo bar
+  invalid command `foo' in line: foo bar
+
+Enter a valid command:
+
+  help
+
+And note that _no_ output is generated.  The anonymous delegate handler for
+the `help' command is not invoked.
+
+Actual Results:
+
+No output.
+
+Expected Results:
+
+The message "insert help text here" displayed to stdout.
+
+How often does this happen? 
+
+Always.
+
+Additional Information:


More information about the mono-bugs mailing list