summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-06-03 14:22:59 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-06-03 14:22:59 +0100
commitebaf3659632c0d5f45ca86593562c6c8367fda67 (patch)
treeb6033cee18e89d7cf52bfa6413f4d1571226478d /libstdc++-v3/include/bits
parentf2b00d2ba461d6dafdeccf6d93828b349b5e7f76 (diff)
Enforce allocator::value_type consistency for containers in C++2a
In previous standards it is undefined for a container and its allocator to have a different value_type. Libstdc++ has traditionally allowed it as an extension, automatically rebinding the allocator to the container's value_type. Since GCC 8.1 that extension has been disabled for C++11 and later when __STRICT_ANSI__ is defined (i.e. for -std=c++11, -std=c++14, -std=c++17 and -std=c++2a). Since the acceptance of P1463R1 into the C++2a draft an incorrect allocator::value_type now requires a diagnostic. This patch implements that by enabling the static_assert for -std=gnu++2a as well. * doc/xml/manual/status_cxx2020.xml: Document P1463R1 status. * include/bits/forward_list.h [__cplusplus > 201703]: Enable allocator::value_type assertion for C++2a. * include/bits/hashtable.h: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_map.h: Likewise. * include/bits/stl_multimap.h: Likewise. * include/bits/stl_multiset.h: Likewise. * include/bits/stl_set.h: Likewise. * include/bits/stl_vector.h: Likewise. * testsuite/23_containers/deque/48101-3_neg.cc: New test. * testsuite/23_containers/forward_list/48101-3_neg.cc: New test. * testsuite/23_containers/list/48101-3_neg.cc: New test. * testsuite/23_containers/map/48101-3_neg.cc: New test. * testsuite/23_containers/multimap/48101-3_neg.cc: New test. * testsuite/23_containers/multiset/48101-3_neg.cc: New test. * testsuite/23_containers/set/48101-3_neg.cc: New test. * testsuite/23_containers/unordered_map/48101-3_neg.cc: New test. * testsuite/23_containers/unordered_multimap/48101-3_neg.cc: New test. * testsuite/23_containers/unordered_multiset/48101-3_neg.cc: New test. * testsuite/23_containers/unordered_set/48101-3_neg.cc: New test. * testsuite/23_containers/vector/48101-3_neg.cc: New test. From-SVN: r271866
Diffstat (limited to 'libstdc++-v3/include/bits')
-rw-r--r--libstdc++-v3/include/bits/forward_list.h2
-rw-r--r--libstdc++-v3/include/bits/hashtable.h2
-rw-r--r--libstdc++-v3/include/bits/stl_deque.h2
-rw-r--r--libstdc++-v3/include/bits/stl_list.h2
-rw-r--r--libstdc++-v3/include/bits/stl_map.h2
-rw-r--r--libstdc++-v3/include/bits/stl_multimap.h2
-rw-r--r--libstdc++-v3/include/bits/stl_multiset.h2
-rw-r--r--libstdc++-v3/include/bits/stl_set.h2
-rw-r--r--libstdc++-v3/include/bits/stl_vector.h2
9 files changed, 9 insertions, 9 deletions
diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h
index 4c277845a51..e686283a432 100644
--- a/libstdc++-v3/include/bits/forward_list.h
+++ b/libstdc++-v3/include/bits/forward_list.h
@@ -421,7 +421,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{
static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value,
"std::forward_list must have a non-const, non-volatile value_type");
-#ifdef __STRICT_ANSI__
+#if __cplusplus > 201703L || defined __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
"std::forward_list must have the same value_type as its allocator");
#endif
diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h
index ab24b5bb537..384e39877f2 100644
--- a/libstdc++-v3/include/bits/hashtable.h
+++ b/libstdc++-v3/include/bits/hashtable.h
@@ -188,7 +188,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
static_assert(is_same<typename remove_cv<_Value>::type, _Value>::value,
"unordered container must have a non-const, non-volatile value_type");
-#ifdef __STRICT_ANSI__
+#if __cplusplus > 201703L || defined __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Value>{},
"unordered container must have the same value_type as its allocator");
#endif
diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h
index 7dcb53823c4..ac76d681ff0 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -824,7 +824,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value,
"std::deque must have a non-const, non-volatile value_type");
-# ifdef __STRICT_ANSI__
+# if __cplusplus > 201703L || defined __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
"std::deque must have the same value_type as its allocator");
# endif
diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h
index 68bab94af1e..701982538df 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -563,7 +563,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus >= 201103L
static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value,
"std::list must have a non-const, non-volatile value_type");
-# ifdef __STRICT_ANSI__
+# if __cplusplus > 201703L || defined __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
"std::list must have the same value_type as its allocator");
# endif
diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h
index 322d0a8290a..b1083d572d6 100644
--- a/libstdc++-v3/include/bits/stl_map.h
+++ b/libstdc++-v3/include/bits/stl_map.h
@@ -118,7 +118,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
__glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
#endif
-#if __cplusplus >= 201103L && defined(__STRICT_ANSI__)
+#if __cplusplus > 201703L || defined __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, value_type>::value,
"std::map must have the same value_type as its allocator");
#endif
diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h
index 4c4ccad3ac0..bb4aece96bf 100644
--- a/libstdc++-v3/include/bits/stl_multimap.h
+++ b/libstdc++-v3/include/bits/stl_multimap.h
@@ -117,7 +117,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
__glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
#endif
-#if __cplusplus >= 201103L && defined(__STRICT_ANSI__)
+#if __cplusplus > 201703L || defined __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, value_type>::value,
"std::multimap must have the same value_type as its allocator");
#endif
diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h
index af733ea34dc..96fa14e2afa 100644
--- a/libstdc++-v3/include/bits/stl_multiset.h
+++ b/libstdc++-v3/include/bits/stl_multiset.h
@@ -109,7 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
static_assert(is_same<typename remove_cv<_Key>::type, _Key>::value,
"std::multiset must have a non-const, non-volatile value_type");
-# ifdef __STRICT_ANSI__
+# if __cplusplus > 201703L || defined __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Key>::value,
"std::multiset must have the same value_type as its allocator");
# endif
diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h
index 3131a7974b0..279b9705d78 100644
--- a/libstdc++-v3/include/bits/stl_set.h
+++ b/libstdc++-v3/include/bits/stl_set.h
@@ -107,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
static_assert(is_same<typename remove_cv<_Key>::type, _Key>::value,
"std::set must have a non-const, non-volatile value_type");
-# ifdef __STRICT_ANSI__
+# if __cplusplus > 201703L || defined __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Key>::value,
"std::set must have the same value_type as its allocator");
# endif
diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h
index dd9382d254d..d33e589498a 100644
--- a/libstdc++-v3/include/bits/stl_vector.h
+++ b/libstdc++-v3/include/bits/stl_vector.h
@@ -397,7 +397,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value,
"std::vector must have a non-const, non-volatile value_type");
-# ifdef __STRICT_ANSI__
+# if __cplusplus > 201703L || defined __STRICT_ANSI__
static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
"std::vector must have the same value_type as its allocator");
# endif