[Mono-bugs] [Bug 70807][Wis] New - mcs generates CS0213 (can not fix an already fixed expression) when csc doesn't
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sat, 25 Dec 2004 23:43:22 -0500 (EST)
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 adamm@san.rr.com.
http://bugzilla.ximian.com/show_bug.cgi?id=70807
--- shadow/70807 2004-12-25 23:43:22.000000000 -0500
+++ shadow/70807.tmp.9323 2004-12-25 23:43:22.000000000 -0500
@@ -0,0 +1,66 @@
+Bug#: 70807
+Product: Mono: Compilers
+Version: unspecified
+OS: All
+OS Details: tested on mono 1.05 for GNU/Linux and Windows
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: adamm@san.rr.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: mcs generates CS0213 (can not fix an already fixed expression) when csc doesn't
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+
+Description of Problem:
+The mcs compiler doesn't match Microsoft's csc compiler in the handling of
+fixed expressions (specifically, fixing basic types such as ints, etc).
+
+This code demonstrates the error:
+
+ using System.Runtime.InteropServices;
+ class Test
+ { [DllImport("SomeLibrary")]
+ static unsafe extern void lowLevelCall(int *pv);
+
+ unsafe void Func(out int i)
+ { fixed(int *pi=&i) lowLevelCall(pi); // CS0213
+ }
+ }
+
+Actual Results:
+$ mcs --unsafe -t:library test.cs
+test.cs(9) error CS0213: You can not fix an already fixed expression
+Compilation failed: 1 error(s), 0 warnings
+
+C:\>csc /unsafe /t:library test.cs
+Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
+for Microsoft (R) .NET Framework version 1.1.4322
+Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
+[compilation successful]
+
+Expected Results:
+I would expect mcs to not generate an error (if mcs' behavior is the
+correct one according to the C# specification, a warning may be justified
+in this case, but an error makes it incompatible with csc).
+
+How often does this happen?
+Consistently.
+
+Additional Information:
+Changing the function to work in mono causes it to fail in Microsoft.NET.
+So the only way to make code like this work seems to be with some #if magic.
+
+ unsafe void Func(out int i)
+ { lowLevelCall(&i); // okay in mcs, CS0212 in csc
+ }
+
+(CS0212 is "You can only take the address of unfixed expression inside of a
+fixed statement initializer")