[Mono-bugs] [Bug 42390][Nor] New - mcs crashes on foreach statement
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Mon, 5 May 2003 16:26:18 -0400 (EDT)
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 arch.robison@intel.com.
http://bugzilla.ximian.com/show_bug.cgi?id=42390
--- shadow/42390 Mon May 5 16:26:18 2003
+++ shadow/42390.tmp.22059 Mon May 5 16:26:18 2003
@@ -0,0 +1,91 @@
+Bug#: 42390
+Product: Mono/MCS
+Version: unspecified
+OS: Red Hat 7.2
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: arch.robison@intel.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: mcs crashes on foreach statement
+
+Please fill in this template when reporting a bug, unless you know what
+you are doing.
+Description of Problem:
+mcs dies with an unhandled exception when compiling a foreach statement
+where the IEnumerable is implemented by a struct.
+
+Steps to reproduce the problem:
+1. Save the following program to a file gorilla.cs:
+using System.Collections;
+
+public class Gorilla {
+
+ public struct Tree: IEnumerable {
+ struct Enumerator: IEnumerator {
+ public bool MoveNext() {
+ return false;
+ }
+ public object Current {
+ get {return null;}
+ }
+ public void Reset() {
+ }
+ }
+
+ public IEnumerator GetEnumerator() {
+ return new Enumerator();
+ }
+ }
+
+ public static void Main() {
+ foreach( int j in new Tree() ) {
+ }
+ }
+}
+2. Compile with "mcs gorilla.cs"
+
+Actual Results:
+Compilation dies with this message:
+Exception caught by the compiler while compiling:
+ Block that caused the problem begin at: gorilla.cs: (22)
+ Block being compiled: [Internal: (1),Internal: (1)]
+
+Unhandled Exception: System.Exception: Expr Mono.CSharp.New of type
+Gorilla+Tree does not implement IMemoryLocation
+in <0x001ad> 00 Mono.CSharp.Foreach:EmitCollectionForeach
+(Mono.CSharp.EmitContext)
+in <0x000fe> 00 Mono.CSharp.Foreach:DoEmit (Mono.CSharp.EmitContext)
+in <0x00045> 00 Mono.CSharp.Statement:Emit (Mono.CSharp.EmitContext)
+in <0x000ac> 00 Mono.CSharp.Block:DoEmit (Mono.CSharp.EmitContext)
+in <0x00065> 00 Mono.CSharp.Block:Emit (Mono.CSharp.EmitContext)
+in <0x000ac> 00 Mono.CSharp.Block:DoEmit (Mono.CSharp.EmitContext)
+in <0x00065> 00 Mono.CSharp.Block:Emit (Mono.CSharp.EmitContext)
+in <0x001bc> 00 Mono.CSharp.EmitContext:EmitTopBlock
+(Mono.CSharp.Block,Mono.CSharp.InternalParameters,Mono.CSharp.Location)
+in <0x00357> 00 Mono.CSharp.EmitContext:EmitTopBlock
+(Mono.CSharp.Block,Mono.CSharp.InternalParameters,Mono.CSharp.Location)
+in <0x0053a> 00 Mono.CSharp.MethodData:Emit
+(Mono.CSharp.TypeContainer,Mono.CSharp.Block,object)
+in <0x00023> 00 Mono.CSharp.Method:Emit (Mono.CSharp.TypeContainer)
+in <0x00297> 00 Mono.CSharp.TypeContainer:Emit ()
+in <0x004c8> 00 Mono.CSharp.RootContext:EmitCode ()
+in <0x0075d> 00 Mono.CSharp.Driver:MainDriver (string[])
+in <0x0000f> 00 Mono.CSharp.Driver:Main (string[])
+
+
+
+Expected Results:
+Successful compilation.
+
+How often does this happen?
+Every time.
+
+Additional Information: