[Mono-bugs] [Bug 75328][Wis] New - a ?? b does not work correctly (gmcs)

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Jun 20 13:24:11 EDT 2005


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 john.caloyannis at gmail.com.

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

--- shadow/75328	2005-06-20 13:24:11.000000000 -0400
+++ shadow/75328.tmp.17618	2005-06-20 13:24:11.000000000 -0400
@@ -0,0 +1,91 @@
+Bug#: 75328
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: ubuntu hoary
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: john.caloyannis at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: a ?? b does not work correctly (gmcs)
+
+mono version 1.1.8
+build from source
+using gmcs
+
+a ?? b does not work correctly
+public class Id
+{
+    public Id () {_idNumber = 0;}
+    public Id (int n) {_idNumber = n;}
+    public override string ToString () {return "" + _idNumber;}
+    private int _idNumber;
+}
+
+public class Test
+{
+    public static void Main()
+    {
+	Id[] id = new Id[3];
+	Id tmpId, c;
+
+	c = new Id(10);
+	id[0] = new Id (0);
+	id[1] = new Id (1);
+	for (int i = 0; i < id.Length; i++) {
+	    tmpId = (id[i] ?? c);
+	    if (id[i] != null) {
+		System.Console.WriteLine (i + ": not null");
+	    } else {
+		System.Console.WriteLine (i + ": is  null");
+	    }
+	    System.Console.WriteLine (i + ":equals(tmpId,id[i]=" + Object.Equals
+(tmpId, id[i]));
+	    System.Console.WriteLine (i + ":equals(tmpId,c    =" + Object.Equals
+(tmpId, c));
+	    System.Console.Write (i + ":");
+	    if (tmpId == null) {
+		System.Console.WriteLine ("null");
+	    } else {
+		System.Console.WriteLine (tmpId.ToString ());
+	    }
+	}
+    }
+}
+
+Steps to reproduce the problem:
+
+compile the aove program: gmcs Test.cs
+run it: mono Test.exe
+
+Actual Results:
+0: not null
+0:equals(tmpId,id[i]=True
+0:equals(tmpId,c    =False
+0:0
+1: is  null
+1:equals(tmpId,id[i]=True
+1:equals(tmpId,c    =False
+1:null
+
+Expected Results:
+0: not null
+0:equals(tmpId,id[i]=True
+0:equals(tmpId,c    =False
+0:0
+1: is  null
+1:equals(tmpId,id[i]=False
+1:equals(tmpId,c    =True
+1:null
+
+How often does this happen? Every time
+
+
+Additional Information:


More information about the mono-bugs mailing list