[Mono-bugs] [Bug 75134][Nor] Changed - CS0233 should be reported for sizeof without unsafe context

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Aug 21 04:45:02 EDT 2005


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 gert.driesen at pandora.be.

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

--- shadow/75134	2005-08-21 04:44:41.000000000 -0400
+++ shadow/75134.tmp.25496	2005-08-21 04:45:02.000000000 -0400
@@ -0,0 +1,64 @@
+Bug#: 75134
+Product: Mono: Compilers
+Version: 1.1
+OS: unknown
+OS Details: 
+Status: REOPENED   
+Resolution: 
+Severity: Unknown
+Priority: Normal
+Component: C#
+AssignedTo: martin at ximian.com                            
+ReportedBy: atsushi at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: CS0233 should be reported for sizeof without unsafe context
+
+Currently mcs does not require unsafe context for "sizeof" operator.
+
+public class Test
+{
+        public void Foo ()
+        {
+                int x = sizeof (int);
+        }
+}
+
+Actual Results:
+
+$ mcs sizeof.cs /unsafe
+sizeof.cs(5) warning CS0219: The variable 'x' is assigned but its value is
+never used
+error CS5001: Program sizeof.exe does not have an entry point defined
+Compilation failed: 1 error(s), 1 warnings
+
+Expected Results:
+
+$ csc sizeof.cs /unsafe /nologo
+sizeof.cs(5,11): error CS0233: sizeof can only be used in an unsafe context
+(consider using System.Runtime.InteropServices.Marshal.SizeOf)
+
+How often does this happen? 
+consistently
+
+Additional Information:
+I haven't checked the C# specification in details so drop it if the spec
+does not require unsafe context.
+
+------- Additional Comments From marek.safar at seznam.cz  2005-06-03 03:37 -------
+csc 2.0 does same. It doesn't require unsafe for simple types.
+
+------- Additional Comments From martin at ximian.com  2005-06-08 14:22 -------
+Same here.
+
+------- Additional Comments From duncan at ximian.com  2005-08-20 11:50 -------
+*** Bug 75861 has been marked as a duplicate of this bug. ***
+
+------- Additional Comments From gert.driesen at pandora.be  2005-08-21 04:44 -------
+Having differences like this one between mcs and csc 1.0 allows for 
+the build to be broken on Windows (when building using csc).
+
+The behaviour of gmcs and csc 2.0 should match, but IMO mcs should 
+match csc 1.0.


More information about the mono-bugs mailing list