[Mono-bugs] [Bug 46220][Nor] New - Illegal by-ref params argument is accepted by compiler and runtime

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Sun, 13 Jul 2003 14:17:58 -0400 (EDT)


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 sestoft@dina.kvl.dk.

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

--- shadow/46220	Sun Jul 13 14:17:57 2003
+++ shadow/46220.tmp.27044	Sun Jul 13 14:17:58 2003
@@ -0,0 +1,74 @@
+Bug#: 46220
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sestoft@dina.kvl.dk               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Illegal by-ref params argument is accepted by compiler and runtime
+
+Description of Problem:
+
+The call m(8, ref v1) compiles ok with mcs 0.25 (while csc 1.1
+rejects it) but the method produces a really weird result, as if a
+reference had been mistaken for an int.  The function call should
+be rejected by the compiler: according to the C# Lang Spec all
+params arguments are by-value.
+
+This is both an mcs (compiler) and a mono (runtime) problem: the
+generated bytecode runs under mono 0.25 but not MS CLR 1.1 (which reports
+that operation could destabilize runtime).
+
+Steps to reproduce the problem:
+1. Compile and run this program:
+
+using System;
+
+class MyTest {
+  public static void Main(String[] args) {
+    int v1;
+    Console.WriteLine(m(8, ref v1));    // Should not be permitted by compiler
+  }
+
+  public static int m(int a, double b) {
+    Console.Write("m(int, double): ");
+    return a + (int)b;
+  }
+
+  public static int m(int x0, params int[] xr) {
+    Console.Write("m(int, int[]): ");
+    int res = x0;
+    foreach (int i in xr) 
+      res += i;
+    return res;
+  }
+}
+
+
+Actual Results:
+
+m(int, int[]): -1084229436
+
+
+Expected Results:
+
+Source program should be rejected by the compiler.
+
+The bytecode should be rejected by the runtime (verifier). 
+
+
+How often does this happen? 
+
+
+Additional Information:
+
+Always on Mono 0.25.