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

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Jun 3 00:57:17 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 atsushi at ximian.com.

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

--- shadow/75134	2005-06-03 00:57:17.000000000 -0400
+++ shadow/75134.tmp.19153	2005-06-03 00:57:17.000000000 -0400
@@ -0,0 +1,48 @@
+Bug#: 75134
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs 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.


More information about the mono-bugs mailing list