Opened 16 years ago

Closed 16 years ago

Last modified 6 years ago

#8966 closed patch

Wrong type promotion for SharedPtr

Reported by: peres Owned by: lordhoto
Priority: blocker Component: --Other--
Version: Keywords:
Cc: Game:

Description

When a SharedPtr<X> is used as the contained type of a Common::List, the remove() method on the latter won't behave as expected.

Instead of invoking SharedPtr::operator==() as defined in common/ptr.h, the comparison at line 206 in common/list.h just promotes both operands to bool, and then compares them. This in turns happen to be true except when only one of the pointers is not initialized, yielding funny results that are easy to imagine.

The attached patch changes the definition of SharedPtr::operator==() to be a member of SharedPtr to fix the problem above.

I hope I got the patch in the right format.

Ticket imported from: #2641592. Ticket imported from: patches/1071.

Attachments (1)

ptr-fix.patch (915 bytes ) - added by peres 16 years ago.
Makes operator==() a member of SharedPtr.

Download all attachments as: .zip

Change History (4)

by peres, 16 years ago

Attachment: ptr-fix.patch added

Makes operator==() a member of SharedPtr.

comment:1 by lordhoto, 16 years ago

Status: newclosed

comment:2 by lordhoto, 16 years ago

Committed with a slight formatting change. Thanks for the patch.

comment:3 by digitall, 6 years ago

Component: --Other--
Note: See TracTickets for help on using tickets.