[Mono-bugs] [Bug 54742][Wis] New - Bug in '+=' operator

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 23 Feb 2004 00:45:28 -0500 (EST)


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 rkumar@novell.com.

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

--- shadow/54742	2004-02-23 00:45:28.000000000 -0500
+++ shadow/54742.tmp.13662	2004-02-23 00:45:28.000000000 -0500
@@ -0,0 +1,67 @@
+Bug#: 54742
+Product: Mono/Runtime
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: rkumar@novell.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: Bug in '+=' operator
+
+Description of Problem:
++= operator does not behave properly in the following code.
+
+Steps to reproduce the problem:
+1. Compile and run the following code
+
+<code>
+using System;
+namespace Test {
+  public class A {
+    public static void Main () {
+      A a = new A ();
+      a.Test ();
+    }
+
+    public void Test ()
+    {
+      A a = new A ();
+
+      // the following is the problematic line
+      _intValue += a.Value + a.Value / 2; 
+
+      // any of following two lines works well,
+      //       _intValue = a.Value + a.Value / 2; 
+      //       _intValue += Value + Value / 2; 
+
+      Console.WriteLine (_intValue);
+    }
+
+    private int _intValue;
+    public readonly int Value = 100;
+  }
+}
+</code>
+
+
+Actual Results:
+50
+
+Expected Results:
+150
+
+How often does this happen? 
+Always.
+
+Additional Information:
+mcs generated exe runs fine on .NET. And exe generated by .NET also gives 
+wrong result on mono (running on Linux).
+
+Thanks to Rodolfo Campero for reporting this bug.