On 06/06/19 14:36 +0100, Jonathan Wakely wrote:
On 03/06/19 14:23 +0100, Jonathan Wakely wrote:
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.

The tests for this extension now fail when run with -std=gnu++2a. This
fixes them. Tested x86_64-linux with various -std options. Committed
to trunk.

I missed a couple more tests that fail with -std=gnu++2a.

Tested x86_64-linux, committed to trunk.


commit 191c471552dfa4784c0721f7813b54eec845bf1a
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Jun 6 15:34:45 2019 +0000

    Fix more tests that fail in C++2a mode
    
            * testsuite/23_containers/unordered_map/requirements/debug_container.cc:
            Do not test allocator rebinding extension for C++2a.
            * testsuite/23_containers/unordered_set/allocator/ext_ptr.cc: Change
            dg-do directive for C++17 and C++2a.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272009 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc
index d6afae9c2e9..903802878d7 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc
@@ -30,7 +30,7 @@ template class __gnu_debug::unordered_map<string, float>;
 template class __gnu_debug::unordered_map<string, int,
                                           hash<string>, equal_to<string>, 
                                           allocator<pair<const string, int>>>;
-#ifndef __STRICT_ANSI__
+#if !defined __STRICT_ANSI__ && __cplusplus <= 201703L
 template class __gnu_debug::unordered_map<string, float,
                                           hash<string>, equal_to<string>, 
                                           allocator<char>>;
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc
index 5daa456e440..b7a63c5e393 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc
@@ -15,7 +15,8 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-do run { target c++11 } }
+// { dg-do run { target { c++11_only || c++14_only } } }
+// { dg-do compile { target c++17 } }
 
 #include <unordered_set>
 #include <memory>

Reply via email to