[Mono-bugs] [Bug 28739][Nor] New - Fixed statement error within unsafe code

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
8 Aug 2002 17:31:36 -0000


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 andy_strain@softhome.net.

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

--- shadow/28739	Thu Aug  8 13:31:36 2002
+++ shadow/28739.tmp.939	Thu Aug  8 13:31:36 2002
@@ -0,0 +1,89 @@
+Bug#: 28739
+Product: Mono/MCS
+Version: unspecified
+OS: Red Hat 7.3
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: andy_strain@softhome.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Fixed statement error within unsafe code
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+The mcs compiler generates an error on the following code, which was copied
+from http://www.softsteel.co.uk/tutorials/cSharp/lesson5.html, but csc
+compiles the code with no warnings or errors.
+
+
+
+Steps to reproduce the problem:
+Compile the following code with `mcs --unsafe Coords.cs` or `csc /unsafe
+Coords.cs`:
+
+---
+using System;
+
+public struct Coords
+{
+  int x;
+  int y;
+
+  unsafe public static void notMain (ref Coords c)
+  {
+    fixed (Coords *p = &c)
+    {
+      p->y = 6;
+      (*p).x = 5;
+    }
+
+    Console.WriteLine (c.y);
+    Console.WriteLine (c.x);
+  }
+
+  public static void Main ()
+  {
+    Coords j = new Coords ();
+    j.x = 72;
+    j.y = 23;
+    Coords.notMain (ref j);
+  }
+}
+---
+
+
+
+Actual Results:
+$ mcs --unsafe Coords.cs
+Coords.cs(10) error CS0213: No need to use fixed statement for parameters
+or local variable declarations (address is already fixed)
+Compilation failed: 1 error(s), 0 warnings
+
+
+
+Expected Results:
+No errors or warnings should occur, like what happens if compiled via `csc
+/unsafe`.
+
+
+
+How often does this happen? 
+Always
+
+
+
+Additional Information:
+I'm using the RPM mono-0.13_baselabs-20020731.
+
+Also, the above mentioned web site does say that fixed should be used, in
+this case, because the ref is from a section of code (Main) not marked unsafe.
+
+Mono and mint both run the csc generated Coords.exe file just fine.