Confused about class equality

Justin Spahr-Summers Justin.SpahrSummers at gmail.com
Tue Apr 6 20:03:43 PDT 2010


On Tue, 06 Apr 2010 22:41:43 -0400, strtr <strtr at spam.com> wrote:
> 
> Justin Spahr-Summers Wrote:
> > 
> > I think he said that he has two distinct object references, but the 
> > value stored in the object(s) changes by changing either one.
> > 
> > In other words, we'd need to see the code.
> 
> I've added this exact sequence:
> 
> 	if( c1 !is null )
> 	{
> 		c1.value = 1;
> 		if( c2 !is null )
> 		{
> 			c2.value = 2;
> 			
> 			if( c1 !is c2 )
> 			{
> 				c1.value = 3;
> 				assert(c2.value == 2 );
> 			}
> 			c2.value = 0;
> 		}
> 		c1.value = 0;
> 	}
> 
> To my understanding this should never fails, yet it does.
> AssertError Failure

Hmm, that is pretty weird. Are you doing any casts anywhere, or any 
pointer arithmetic/tricks?

The only thing that I can think of is that you might've somehow 
unintentionally fooled the compiler/runtime by coercing some types 
somewhere.

If not, it might comprise a valid bug report.


More information about the Digitalmars-d-learn mailing list