[Webkit-unassigned] [Bug 12750] New: Vector compare operator is broken

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Feb 12 18:12:33 PST 2007


           Summary: Vector compare operator is broken
           Product: WebKit
           Version: 420+ (nightly)
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: occupant4 at gmail.com

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.

------- Comment #1 from occupant4 at gmail.com  2007-02-12 18:12 PDT -------
Created an attachment (id=13144)
 --> (http://bugs.webkit.org/attachment.cgi?id=13144&action=view)
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.

Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

More information about the webkit-unassigned mailing list