gtest fails to build due to integer type mismatch in WTF::insertIntoBoundedVector()
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 Sep 2013 03:46:22 +0000 (03:46 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 Sep 2013 03:46:22 +0000 (03:46 +0000)
<http://webkit.org/b/120983>

Reviewed by Dan Bernstein.

Fixes the following build failure:

    WebKitBuild/Debug/usr/local/include/wtf/StdLibExtras.h:266:23: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Werror,-Wshorten-64-to-32]
    for (unsigned i = size; i-- > index + 1;)
                  ~   ^~~~

* wtf/StdLibExtras.h:
(WTF::insertIntoBoundedVector): Use size_t instead of unsigned
as for loop index variable.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155280 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/StdLibExtras.h

index 87ac8aa56035ad9642f422943cf9b0d037e1f59e..66ad34720ebc4f88d7359aa7b23f1a3c85297240 100644 (file)
@@ -1,3 +1,20 @@
+2013-09-07  David Kilzer  <ddkilzer@apple.com>
+
+        gtest fails to build due to integer type mismatch in WTF::insertIntoBoundedVector()
+        <http://webkit.org/b/120983>
+
+        Reviewed by Dan Bernstein.
+
+        Fixes the following build failure:
+
+            WebKitBuild/Debug/usr/local/include/wtf/StdLibExtras.h:266:23: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Werror,-Wshorten-64-to-32]
+            for (unsigned i = size; i-- > index + 1;)
+                          ~   ^~~~
+
+        * wtf/StdLibExtras.h:
+        (WTF::insertIntoBoundedVector): Use size_t instead of unsigned
+        as for loop index variable.
+
 2013-09-07  Anders Carlsson  <andersca@apple.com>
 
         Remove NonCopyableSort.h from WTF
 2013-09-07  Anders Carlsson  <andersca@apple.com>
 
         Remove NonCopyableSort.h from WTF
index a4cc7887bc0851841333e2ce18b2fbab95c73b0f..a3c6f4fb8a30bc1499df43c1f64a5b7416943a0b 100644 (file)
@@ -263,7 +263,7 @@ inline ArrayElementType* approximateBinarySearch(const ArrayType& array, size_t
 template<typename VectorType, typename ElementType>
 inline void insertIntoBoundedVector(VectorType& vector, size_t size, const ElementType& element, size_t index)
 {
 template<typename VectorType, typename ElementType>
 inline void insertIntoBoundedVector(VectorType& vector, size_t size, const ElementType& element, size_t index)
 {
-    for (unsigned i = size; i-- > index + 1;)
+    for (size_t i = size; i-- > index + 1;)
         vector[i] = vector[i - 1];
     vector[index] = element;
 }
         vector[i] = vector[i - 1];
     vector[index] = element;
 }