Bug 320565 (MONO77805) - [ANONYMOUS METHODS] (FIXED) CS1629: Iterator implementation in unsafe class fails to compile
Summary: [ANONYMOUS METHODS] (FIXED) CS1629: Iterator implementation in unsafe class f...
Status: RESOLVED FIXED
Alias: MONO77805
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-16 22:52 UTC by horst.reiterer
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:51:34 UTC


---- Reported by horst.reiterer@mind-breeze.com 2006-03-16 15:52:07 MST ----

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



---- Additional Comments From marek.safar@seznam.cz 2006-03-16 18:13:14 MST ----

I think my IResolveContext refactoring fixed this issue for mcs.
But this is not yet part of gmcs.



---- Additional Comments From martin@ximian.com 2006-10-04 18:19:17 MST ----

Fixed in SVN.


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>Red Hat Enterprise Linux 4</cf_op_sys_details>
Unknown operating system other. Setting to default OS "Other".