Bugzilla – Bug 316171
[PATCH] my_delegate == null calls MulticastDelegate::op_Equality
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by bmaurer@users.sf.net 2004-10-03 20:47:18 MST ---- Take the following test case: using System; class X { delegate void D (); static void Main () { D d = null; if (d == null) Console.WriteLine ("X"); if (d != null) Console.WriteLine ("Y"); } } MSFT just does brtrue / brfalse on d. We call MulticastDelegate.op_Equalitity. We might do this with other reference types that have operator overloads ---- Additional Comments From bmaurer@users.sf.net 2004-10-03 20:57:16 MST ---- Created an attachment (id=166874) patch ---- Additional Comments From bmaurer@users.sf.net 2004-10-03 20:59:32 MST ---- This just generalizes the special case we already had for strings to handle other reference types. I'd note that this is not just an optimization. COnsider the following impl of equals: public static bool operator == (X x, X y) { if ((object)x == (object)y) return true; if (x == null || y == null) return false; without my patch, this will become unbound recursion. ---- Additional Comments From bmaurer@users.sf.net 2004-10-03 23:22:13 MST ---- fixed in both branches ---- Additional Comments From rharinath@novell.com 2005-04-18 06:39:18 MST ---- Fix caused #74481. As for the infloop, I think it should (cf. behaviour with CSC 1.1 and 2.0). ---- Additional Comments From rharinath@novell.com 2005-04-18 11:14:01 MST ---- Fixed more conservatively, as discussed on mono-devel-list. Imported an attachment (id=166874) Unknown operating system unknown. Setting to default OS "Other".