[Mono-bugs] [Bug 77805][Nor] New - CS1629: Iterator implementation
in unsafe class fails to compile
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Thu Mar 16 15:52:08 EST 2006
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 horst.reiterer at mind-breeze.com.
http://bugzilla.ximian.com/show_bug.cgi?id=77805
--- shadow/77805 2006-03-16 15:52:08.000000000 -0500
+++ shadow/77805.tmp.16524 2006-03-16 15:52:08.000000000 -0500
@@ -0,0 +1,70 @@
+Bug#: 77805
+Product: Mono: Compilers
+Version: 1.1
+OS: other
+OS Details: Red Hat Enterprise Linux 4
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com
+ReportedBy: horst.reiterer at mind-breeze.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: CS1629: Iterator implementation in unsafe class fails to compile
+
+The following testcase fails to compile with Mono 1.1.13's gmcs
+(/d:FAILURE). The
+testcase defines an unsafe class with an iterator implementation which
+calls a method containing unsafe code. If only the method itself is marked
+as unsafe, compilation succeeds. In Microsoft's csc case, compilation
+succeeds in both cases.
+
+using System;
+using System.Collections.Generic;
+
+#if FAILURE
+unsafe
+#endif
+class Test
+{
+ public static void Main()
+ {
+ foreach (int item in GetItems()) {
+ Console.WriteLine(item);
+ }
+ }
+
+ public static unsafe int GetItem()
+ {
+ byte[] value = new byte[] { 0xDE, 0xAD, 0xBE, 0xEF };
+
+ fixed (byte* valueptr = value) {
+ return *(int*)valueptr;
+ }
+ }
+
+ public static IEnumerable<int> GetItems()
+ {
+ yield return GetItem();
+ }
+}
+
+Steps to reproduce the problem:
+1. gmcs /d:FAILURE testcase.cs
+
+Actual Results:
+
+testcase.cs(27,5): error CS1629: Unsafe code may not appear in iterators
+Compilation failed: 1 error(s), 0 warnings
+
+Expected Results:
+
+Successful compilation with /d:FAILURE
+
+How often does this happen?
+
+100 out of 100 times
More information about the mono-bugs
mailing list