[Mono-bugs] [Bug 45314][Maj] New - wrong result of assignment expression

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Mon, 23 Jun 2003 17:20:20 -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 sestoft@dina.kvl.dk.

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

--- shadow/45314	Mon Jun 23 17:20:20 2003
+++ shadow/45314.tmp.1312	Mon Jun 23 17:20:20 2003
@@ -0,0 +1,59 @@
+Bug#: 45314
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sestoft@dina.kvl.dk               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: wrong result of assignment expression
+
+Description of Problem:
+
+The result of the assignment expression (n = m) inside the assignment in
+the while-loop is n, but should be m of course.  The problem is not
+observed in simpler contexts.
+
+Steps to reproduce the problem:
+1. Compile and execute the program below
+
+Actual Results:
+
+Gcd(6,  2) = 6
+Gcd(15, 7) = 15
+
+Expected Results:
+
+Gcd(6,  2) = 2
+Gcd(15, 7) = 1
+
+
+How often does this happen? 
+
+Always in mono-0.23 for Debian Linux; probably an MCS code generation
+problem.  Happens for long operations too. 
+
+Additional Information:
+
+Sample program:
+
+class TestGcd {
+  public static void Main(String[] args) {
+    Console.WriteLine("Gcd(6,  2) = " + Gcd(6,  2));
+    Console.WriteLine("Gcd(15, 7) = " + Gcd(15, 7));
+  }
+
+  private static int Gcd(int m, int n) {
+    while (m != 0) 
+      m = n % (n = m); 
+    return n;
+  }
+}