[cfe-commits] [libcxx] r136540 - /libcxx/trunk/include/vector

Sean Hunt scshunt at csclub.uwaterloo.ca
Fri Jul 29 16:31:58 PDT 2011


Author: coppro
Date: Fri Jul 29 18:31:58 2011
New Revision: 136540

URL: http://llvm.org/viewvc/llvm-project?rev=136540&view=rev
Log:
Explicitly invoke the size_type specialization of max and min. This
avoids bugs where, when the allocator's size_type was smaller than int,
the multiplication or division would cause integral promotions and, with
two different integer types as arguments, deduction of the template
arguments would fail.

Modified:
    libcxx/trunk/include/vector

Modified: libcxx/trunk/include/vector
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=136540&r1=136539&r2=136540&view=diff
==============================================================================
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Fri Jul 29 18:31:58 2011
@@ -794,7 +794,7 @@
 typename vector<_Tp, _Allocator>::size_type
 vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
 {
-    return _VSTD::min(__alloc_traits::max_size(this->__alloc()), numeric_limits<size_type>::max() / 2);  // end() >= begin(), always
+    return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()), numeric_limits<size_type>::max() / 2);  // end() >= begin(), always
 }
 
 //  Precondition:  __new_size > capacity()
@@ -809,7 +809,7 @@
     const size_type __cap = capacity();
     if (__cap >= __ms / 2)
         return __ms;
-    return _VSTD::max(2*__cap, __new_size);
+    return _VSTD::max<size_type>(2*__cap, __new_size);
 }
 
 //  Default constructs __n objects starting at __end_





More information about the cfe-commits mailing list