dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]An operator overloading bug


From: Rhys Weatherley
Subject: Re: [DotGNU]An operator overloading bug
Date: Fri, 30 Aug 2002 08:44:06 +1000

Gopal V wrote:

> I tried this for pnet and found that an issue existed in pnetlib .
> Also that the System.Version class is affected by this bug. Since
> we can only ignore this issue (as per undecidability problem :-)
> we should solve it in pnetlib...

Some more information for adventurers ...

The circularity in this case comes in "Version.Equals" and
"Version.CompareTo", when they check for "null".  The null
check calls the operator, which then calls "CompareTo/Equals"
again, etc, etc, etc.

One way to break these kinds of circularities in C# is to
use "Object.ReferenceEquals" to check for "null" instead of
"==".  The "Object.ReferenceEquals" method avoids the check
for overloaded operators.

Another way is to explicitly cast the object reference to
"Object" before comparing.  This strips the reference of
its type so that the compiler won't check for operators.
"System.MulticastDelegate" uses this trick a lot to avoid
circularities.

Anyone want to go into pnetlib to make the fix and search
for similar problems?

Cheers,

Rhys.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]