mail-archives/mono-bugs/2003-July/006345.html

155 строки
4.6 KiB
HTML
Исходник Постоянная ссылка Обычный вид История

2019-06-06 22:03:35 +03:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-bugs] [Bug 46222][Nor] New - Iterator (yield statement) implementation wrong
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:bugzilla-daemon%40rocky.ximian.com">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="006344.html">
<LINK REL="Next" HREF="006346.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-bugs] [Bug 46222][Nor] New - Iterator (yield statement) implementation wrong
</H1>
<B>bugzilla-daemon@rocky.ximian.com
</B>
<A HREF="mailto:bugzilla-daemon%40rocky.ximian.com"
TITLE="[Mono-bugs] [Bug 46222][Nor] New - Iterator (yield statement) implementation wrong">bugzilla-daemon@rocky.ximian.com
</A><BR>
<I>Sun, 13 Jul 2003 15:40:32 -0400 (EDT)</I>
<P><UL>
<LI> Previous message: <A HREF="006344.html">[Mono-bugs] [Bug 46221][Wis] New - monodis does not use full methodref name for features
</A></li>
<LI> Next message: <A HREF="006346.html">[Mono-bugs] [Bug 45876][Nor] Changed - Attributes on operators are specified twice in the MSIL
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#6345">[ date ]</a>
<a href="thread.html#6345">[ thread ]</a>
<a href="subject.html#6345">[ subject ]</a>
<a href="author.html#6345">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>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 <A HREF="mailto:sestoft@dina.kvl.dk.">sestoft@dina.kvl.dk.</A>
<A HREF="http://bugzilla.ximian.com/show_bug.cgi?id=46222">http://bugzilla.ximian.com/show_bug.cgi?id=46222</A>
--- shadow/46222 Sun Jul 13 15:40:32 2003
+++ shadow/46222.tmp.19879 Sun Jul 13 15:40:32 2003
@@ -0,0 +1,91 @@
+Bug#: 46222
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: <A HREF="mailto:mono-bugs@ximian.com">mono-bugs@ximian.com</A>
+ReportedBy: <A HREF="mailto:sestoft@dina.kvl.dk">sestoft@dina.kvl.dk</A>
+QAContact: <A HREF="mailto:mono-bugs@ximian.com">mono-bugs@ximian.com</A>
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Iterator (yield statement) implementation wrong
+
+Description of Problem:
+
+The implementation of the yield statement in C# 2 iterators refers to wrong
+field of proxy class or enclosing class and therefore produces wrong
+results. Apparently references to the b field from the enclosing class Seq
+are somehow confused with the proxy-local field i, although I cannot see
+from the disassembled bytecode exactly what goes wrong. If the iterator
+uses only three (not four) fields from the enclosing class, everything is ok.
+
+Steps to reproduce the problem:
+1. Compile and run this program with mcs -v2:
+
+using System;
+using System.Collections;
+
+class Seq : IEnumerable {
+ private readonly int m, n, k, b; // Represents the sequence b + k * [m..n]
+
+ public Seq(int m, int n, int k, int b) {
+ this.m = m; this.n = n; this.k = k; this.b = b;
+ }
+
+ public IEnumerator GetEnumerator() {
+ for (int i=m; i&lt;=n; i++) {
+ Console.WriteLine(&quot;m={0} n={1} k={2} b={3} i={4}&quot;, m, n, k, b, i);
+ yield b + k * i;
+ }
+ }
+}
+
+class MyTest {
+ public static void Main(String[] args) {
+ Seq seq = new Seq(0, 4, 1, 0);
+ foreach (int i in seq)
+ Console.WriteLine(i);
+ }
+}
+
+
+Actual Results:
+
+m=0 n=4 k=1 b=0 i=0
+0
+m=0 n=4 k=1 b=1 i=1
+2
+m=0 n=4 k=1 b=2 i=2
+4
+m=0 n=4 k=1 b=3 i=3
+6
+m=0 n=4 k=1 b=4 i=4
+8
+
+
+Expected Results:
+
+m=0 n=4 k=1 b=1 i=0
+0
+m=0 n=4 k=1 b=1 i=1
+1
+m=0 n=4 k=1 b=1 i=2
+2
+m=0 n=4 k=1 b=1 i=3
+3
+m=0 n=4 k=1 b=1 i=4
+4
+
+
+How often does this happen?
+
+Always on mono 0.25.
+
+
+Additional Information:
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="006344.html">[Mono-bugs] [Bug 46221][Wis] New - monodis does not use full methodref name for features
</A></li>
<LI> Next message: <A HREF="006346.html">[Mono-bugs] [Bug 45876][Nor] Changed - Attributes on operators are specified twice in the MSIL
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#6345">[ date ]</a>
<a href="thread.html#6345">[ thread ]</a>
<a href="subject.html#6345">[ subject ]</a>
<a href="author.html#6345">[ author ]</a>
</LI>
</UL>
</body></html>