Bug 316171 (MONO67410) - [PATCH] my_delegate == null calls MulticastDelegate::op_Equality
Summary: [PATCH] my_delegate == null calls MulticastDelegate::op_Equality
Status: RESOLVED FIXED
Alias: MONO67410
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Raja R Harinath
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-04 03:47 UTC by Ben Maurer
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
patch (878 bytes, patch)
2004-10-04 03:57 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 18:55:26 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".