Skip to content

Commit

Permalink
Issue 6618 - TypeInfo_Struct.equals should prefer xopEquals than poin…
Browse files Browse the repository at this point in the history
…ter equality
  • Loading branch information
9rnsr committed Sep 14, 2011
1 parent ea08cd4 commit 76f732c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/object_.d
Original file line number Diff line number Diff line change
Expand Up @@ -941,12 +941,12 @@ class TypeInfo_Struct : TypeInfo

override equals_t equals(in void* p1, in void* p2)
{
if (p1 == p2)
return true;
else if (!p1 || !p2)
if (!p1 || !p2)
return false;
else if (xopEquals)
return (*xopEquals)(p1, p2);
else if (p1 == p2)
return true;
else
// BUG: relies on the GC not moving objects
return memcmp(p1, p2, init.length) == 0;
Expand Down Expand Up @@ -1024,6 +1024,19 @@ class TypeInfo_Struct : TypeInfo
}
}

unittest
{
struct S
{
const bool opEquals(ref const S rhs)
{
return false;
}
}
S s;
assert(!typeid(S).equals(&s, &s));
}

class TypeInfo_Tuple : TypeInfo
{
TypeInfo[] elements;
Expand Down
2 changes: 1 addition & 1 deletion win32.mak
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ $(DRUNTIME): $(OBJS) $(SRCS) win32.mak
$(DMD) -lib -of$(DRUNTIME) -Xfdruntime.json $(DFLAGS) $(SRCS) $(OBJS)

unittest : $(SRCS) $(DRUNTIME) src\unittest.d
$(DMD) $(UDFLAGS) -L/co -unittest src\unittest.d $(SRCS) $(DRUNTIME) -debuglib=$(DRUNTIME_BASE) -defaultlib=$(DRUNTIME_BASE)
$(DMD) $(UDFLAGS) -L/co -unittest src\unittest.d $(SRCS) $(DRUNTIME) -debuglib=$(DRUNTIME) -defaultlib=$(DRUNTIME)

zip: druntime.zip

Expand Down

0 comments on commit 76f732c

Please sign in to comment.