RESOLVED FIXED 12750
Vector compare operator is broken
https://bugs.webkit.org/show_bug.cgi?id=12750
Summary Vector compare operator is broken
Dex Deacon
Reported 2007-02-12 14:31:54 PST
Try running this code: Vector<char> a, b; a.fill('x', 10); b.fill('x', 10); ASSERT(a == b); The assertion will fail. There are two problems here: 1. The (templated) operator== for Vectors is defined as returning void, so it never actually gets instantiated! 2. Even if #1 is fixed, the operator== still isn't used by the compiler. Instead, the implicit cast to char* is being called (Vector<char>::operator char*()), and the data pointers are being compared. This affects a few other operator== functions that depend on Vector<T>::operator==, such as FormDataElement. The only reasonable solution I can think of is to remove the implicit cast, and just use the .data() accessor everywhere. Tested on Mac and Windows.
Attachments
patch for Vector comparison operators (2.87 KB, patch)
2007-02-12 18:12 PST, Dex Deacon
darin: review+
Dex Deacon
Comment 1 2007-02-12 18:12:31 PST
Created attachment 13144 [details] patch for Vector comparison operators Actually, it turns out that after fixing #1, the implicit cast was being used only because the operator== was still broken in other ways. Specifically, it didn't accept const Vectors, so it wouldn't be used for all callers. After fixing Vector's operator==, I had to also add an operator!= for a class that previously wasn't being compared at all in RenderStyle.h.
Darin Adler
Comment 2 2007-02-12 18:15:06 PST
Comment on attachment 13144 [details] patch for Vector comparison operators r=me
Darin Adler
Comment 3 2007-02-12 18:15:33 PST
I also think we should remove the implicit cast.
Darin Adler
Comment 4 2007-02-13 10:43:21 PST
Committed revision 19606.
Note You need to log in before you can comment on or make changes to this bug.