[Webkit-unassigned] [Bug 14967] New: Reduce wtf::Vector::operator[]() overloads to eliminate compiler warnings on Windows 64-bit

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 14 13:06:03 PDT 2007


http://bugs.webkit.org/show_bug.cgi?id=14967

           Summary: Reduce wtf::Vector::operator[]() overloads to eliminate
                    compiler warnings on Windows 64-bit
           Product: WebKit
           Version: 522+ (nightly)
          Platform: PC
        OS/Version: Windows XP
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: WebCore Misc.
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: zerodpx at gmail.com


Vector.h provides an at(size_t) accessor and a series of operator[]()s, all of
which call at(), but none of which take a size_t.  On Windows 64-bit, where
size_t is a 64-bit type, this results in compiler warnings when calling
Vector[size_t].

It used to be the case that operator[]() _did_ take a size_t, and, ironically,
this was changed to eliminate Windows compiler warnings.  But the change was
the wrong fix: the actual problem at the time (I think, from inspection of the
original source) was that there was also an overload which took an int, meaning
that promotion from shorter types was ambiguous.

Inspection of the STL headers suggested that providing only a size_t version
should always be safe (which makes sense; it should be at least as large a type
as almost any parameter a caller would actually provide, so autopromotion
should work OK).  After writing an initial patch to do this, I discovered that
another, scary operator was causing overload resolution ambiguity: operator
T*().  This allows callers to treat Vectors directly as pointers.  I consider
this scary since it can result in silent conversion to bool in ways callers
don't expect.  On IRC, Maciej also noted that this operator was "questionable".

So, I have a patch that eliminates this operator as well, and changes all
callers who depended on it to doing the right thing (which usually meant adding
a call to ".data()").  This shouldn't make any code slower as operator T* was
just an inline call to data() anyway.

I have successfully compiled this patch on Windows without any compiler
warnings.  Still need someone to test it on Mac.  Will attach the patch
shortly.


-- 
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