[Mono-bugs] [Bug 52279][Maj] New - t.Me.blah ++; calls get_Me twice

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 24 May 2004 17:38:32 -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 miguel@ximian.com.

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

--- shadow/52279	2004-05-24 17:38:32.000000000 -0400
+++ shadow/52279.tmp.11537	2004-05-24 17:38:32.000000000 -0400
@@ -0,0 +1,48 @@
+Bug#: 52279
+Product: Mono: Compilers
+Version: unspecified
+OS: unknown
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Major
+Component: C#
+AssignedTo: martin@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: t.Me.blah ++; calls get_Me twice
+
+Description of Problem:
+This code can produce some unexpected side effects, and could cause perf
+problems
+
+Steps to reproduce the problem:
+class T {
+	T Me { get { calls ++; return this; } }
+	int blah = 0, calls = 0;
+	
+	static void Main () {
+		T t = new T ();
+		t.Me.blah ++;
+		System.Console.WriteLine (t.calls);
+	}
+}
+
+Actual Results:
+2
+
+Expected Results:
+1
+
+Additional Information:
+Imagine if this was something like:
+a [someComplex (expression [that [takes] * time])].field ++;
+
+We need to use a temporary helper here, or we could figure out some dup'ing
+method.
+
+Assigning to self.