[libcxx] r287381 - [libcxx] [test] D26813: allocator<const T> is non-Standard.

Stephan T. Lavavej via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 18 13:54:32 PST 2016


Author: stl_msft
Date: Fri Nov 18 15:54:31 2016
New Revision: 287381

URL: http://llvm.org/viewvc/llvm-project?rev=287381&view=rev
Log:
[libcxx] [test] D26813: allocator<const T> is non-Standard.

N4582 17.6.3.5 [allocator.requirements] says that allocators are given
cv-unqualified object types, and N4582 20.9.9 [default.allocator]
implies that allocator<const T> is ill-formed (due to colliding
address() overloads). Therefore, tests for allocator<const T>
should be marked as libcxx-specific (if not removed outright).

Modified:
    libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
    libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp

Modified: libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp?rev=287381&r1=287380&r2=287381&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp Fri Nov 18 15:54:31 2016
@@ -16,6 +16,8 @@
 #include <memory>
 #include <cassert>
 
+#include "test_macros.h"
+
 template <typename T>
 void test_max(size_t count)
 {
@@ -27,23 +29,19 @@ void test_max(size_t count)
     }
 }
 
-int main()
+template <typename T>
+void test()
 {
-    {  // Bug 26812 -- allocating too large
-        typedef double T;
-        std::allocator<T> a;
-        test_max<T> (a.max_size() + 1);                // just barely too large
-        test_max<T> (a.max_size() * 2);                // significantly too large
-        test_max<T> (((size_t) -1) / sizeof(T) + 1);   // multiply will overflow
-        test_max<T> ((size_t) -1);                     // way too large
-    }
+    // Bug 26812 -- allocating too large
+    std::allocator<T> a;
+    test_max<T> (a.max_size() + 1);                // just barely too large
+    test_max<T> (a.max_size() * 2);                // significantly too large
+    test_max<T> (((size_t) -1) / sizeof(T) + 1);   // multiply will overflow
+    test_max<T> ((size_t) -1);                     // way too large
+}
 
-    {
-        typedef const double T;
-        std::allocator<T> a;
-        test_max<T> (a.max_size() + 1);                // just barely too large
-        test_max<T> (a.max_size() * 2);                // significantly too large
-        test_max<T> (((size_t) -1) / sizeof(T) + 1);   // multiply will overflow
-        test_max<T> ((size_t) -1);                     // way too large
-    }
+int main()
+{
+    test<double>();
+    LIBCPP_ONLY(test<const double>());
 }

Modified: libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp?rev=287381&r1=287380&r2=287381&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp Fri Nov 18 15:54:31 2016
@@ -32,6 +32,8 @@
 #include <type_traits>
 #include <cstddef>
 
+#include "test_macros.h"
+
 int main()
 {
     static_assert((std::is_same<std::allocator<char>::size_type, std::size_t>::value), "");
@@ -45,7 +47,7 @@ int main()
                                 std::allocator<int> >::value), "");
 
     static_assert((std::is_same<std::allocator<      char>::is_always_equal, std::true_type>::value), "");
-    static_assert((std::is_same<std::allocator<const char>::is_always_equal, std::true_type>::value), "");
+    LIBCPP_STATIC_ASSERT((std::is_same<std::allocator<const char>::is_always_equal, std::true_type>::value), "");
 
     std::allocator<char> a;
     std::allocator<char> a2 = a;




More information about the cfe-commits mailing list