[PATCH] Enforce allocator::value_type consistency for containers in C++2a
Jonathan Wakely
jwakely@redhat.com
Mon Jun 3 21:34:00 GMT 2019
On 03/06/19 23:17 +0200, Rainer Orth wrote:
>Hi Jonathan,
>
>> 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.
>>
>> Tested x86_64-linux, committed to trunk.
>
>this patch caused a couple of testsuite regressions:
>
>+FAIL: g++.old-deja/g++.other/headers1.C -std=c++98 (test for excess errors)
>+UNRESOLVED: g++.old-deja/g++.other/headers1.C -std=c++98 compilation failed to produce executable
>
>Excess errors:
>/var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/libstdc++-v3/include/bits/stl_map.h:122:21: error: 'is_same' has not been declared
>/var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/libstdc++-v3/include/bits/stl_map.h:122:28: error: expected ',' or '...' before '<' token
>/var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/libstdc++-v3/include/bits/stl_multimap.h:121:21: error: 'is_same' has not been declared
>/var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/libstdc++-v3/include/bits/stl_multimap.h:121:28:
>error: expected ',' or '...' before '<' token
>
>+FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98 (test for excess errors)
>
>+FAIL: g++.dg/tree-ssa/copyprop.C (test for excess errors)
>
>Same error, seen everywhere (i386-pc-solaris2.11, sparc-sun-solaris2.11,
>aarch64-unknown-linux-gnu, x86_64-pc-linux-gnu, ...).
Doh. In those files the existing static_assert wasn't guarded by a
check for C++11 or later. I'm testing this patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 1590 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190603/0bbbec99/attachment.bin>
More information about the Gcc-patches
mailing list