* include/bits/alloc_traits.h (_S_max_size): Implement LWG 2466.
* testsuite/20_util/allocator_traits/members/max_size.cc: Adjust.
* testsuite/23_containers/forward_list/allocator/minimal.cc:
Likewise.
* testsuite/23_containers/map/allocator/minimal.cc: Likewise.
* testsuite/23_containers/multimap/allocator/minimal.cc: Likewise.
* testsuite/23_containers/multiset/allocator/minimal.cc: Likewise.
* testsuite/23_containers/set/allocator/minimal.cc: Likewise.
* testsuite/23_containers/unordered_map/allocator/minimal.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/allocator/minimal.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/allocator/minimal.cc:
Likewise.
* testsuite/23_containers/unordered_set/allocator/minimal.cc:
Likewise.
* testsuite/util/testsuite_allocator.h: Remove unused parameter.
From-SVN: r223154
2015-05-13 Jonathan Wakely <jwakely@redhat.com>
+ * include/bits/alloc_traits.h (_S_max_size): Implement LWG 2466.
+ * testsuite/20_util/allocator_traits/members/max_size.cc: Adjust.
+ * testsuite/23_containers/forward_list/allocator/minimal.cc:
+ Likewise.
+ * testsuite/23_containers/map/allocator/minimal.cc: Likewise.
+ * testsuite/23_containers/multimap/allocator/minimal.cc: Likewise.
+ * testsuite/23_containers/multiset/allocator/minimal.cc: Likewise.
+ * testsuite/23_containers/set/allocator/minimal.cc: Likewise.
+ * testsuite/23_containers/unordered_map/allocator/minimal.cc:
+ Likewise.
+ * testsuite/23_containers/unordered_multimap/allocator/minimal.cc:
+ Likewise.
+ * testsuite/23_containers/unordered_multiset/allocator/minimal.cc:
+ Likewise.
+ * testsuite/23_containers/unordered_set/allocator/minimal.cc:
+ Likewise.
+ * testsuite/util/testsuite_allocator.h: Remove unused parameter.
+
* acinclude.m4 (GLIBCXX_ENABLE_FILESYSTEM_TS): Re-enable on solaris.
* configure: Regenerate.
typename = _Require<__not_<__has_max_size<_Alloc2>>>>
static size_type
_S_max_size(_Alloc2&, ...)
- { return __gnu_cxx::__numeric_traits<size_type>::__max; }
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2466. allocator_traits::max_size() default behavior is incorrect
+ return __gnu_cxx::__numeric_traits<size_type>::__max
+ / sizeof(value_type);
+ }
template<typename _Alloc2>
struct __select_helper
typedef std::allocator_traits<unsized_allocator<X>> traits_type;
traits_type::allocator_type a;
auto size = std::numeric_limits<traits_type::size_type>::max();
- VERIFY( traits_type::max_size(a) == size );
+ VERIFY( traits_type::max_size(a) == size / sizeof(X) );
+}
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef std::allocator_traits<unsized_allocator<int>> traits_type;
+ traits_type::allocator_type a;
+ auto size = std::numeric_limits<traits_type::size_type>::max();
+ VERIFY( traits_type::max_size(a) == size / sizeof(int) );
}
int main()
{
test01();
test02();
+ test03();
}
typedef std::forward_list<T, alloc_type> test_type;
test_type v(alloc_type{});
v.push_front(T());
- VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
+ VERIFY( v.max_size() < traits_type::max_size(v.get_allocator()) );
}
int main()
typedef std::map<T, U, Cmp, alloc_type> test_type;
test_type v(alloc_type{});
v = { test_type::value_type{} };
- VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
+ VERIFY( v.max_size() < traits_type::max_size(v.get_allocator()) );
}
int main()
typedef std::multimap<T, U, Cmp, alloc_type> test_type;
test_type v(alloc_type{});
v = { test_type::value_type{} };
- VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
+ VERIFY( v.max_size() < traits_type::max_size(v.get_allocator()) );
}
int main()
typedef std::multiset<T, Cmp, alloc_type> test_type;
test_type v(alloc_type{});
v = { test_type::value_type{} };
- VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
+ VERIFY( v.max_size() < traits_type::max_size(v.get_allocator()) );
}
int main()
typedef std::set<T, Cmp, alloc_type> test_type;
test_type v(alloc_type{});
v = { test_type::value_type{} };
- VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
+ VERIFY( v.max_size() < traits_type::max_size(v.get_allocator()) );
}
int main()
test_type v(alloc_type{});
v.emplace(std::piecewise_construct,
std::make_tuple(T()), std::make_tuple(T()));
- VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
+ VERIFY( v.max_size() < traits_type::max_size(v.get_allocator()) );
}
int main()
test_type v(alloc_type{});
v.emplace(std::piecewise_construct,
std::make_tuple(T()), std::make_tuple(T()));
- VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
+ VERIFY( v.max_size() < traits_type::max_size(v.get_allocator()) );
}
int main()
typedef std::unordered_multiset<T, hash, equal_to, alloc_type> test_type;
test_type v(alloc_type{});
v.insert(T());
- VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
+ VERIFY( v.max_size() < traits_type::max_size(v.get_allocator()) );
}
int main()
typedef std::unordered_set<T, hash, equal_to, alloc_type> test_type;
test_type v(alloc_type{});
v.insert(T());
- VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
+ VERIFY( v.max_size() < traits_type::max_size(v.get_allocator()) );
}
int main()
SimpleAllocator() noexcept { }
template <class T>
- SimpleAllocator(const SimpleAllocator<T>& other) { }
+ SimpleAllocator(const SimpleAllocator<T>&) { }
Tp *allocate(std::size_t n)
{ return std::allocator<Tp>().allocate(n); }