aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
AgeCommit message (Collapse)AuthorFilesLines
2020-06-30Revert "Add a __nonnnull__ attribute to std::string's _CharT* constructor"Ville Voutilainen3-59/+0
This reverts commit b26fd416fb0a734d3f3e56629b6dff2e3c25dd40.
2020-06-29Daily bump.GCC Administrator1-0/+32
2020-06-29Add a __nonnnull__ attribute to std::string's _CharT* constructorVille Voutilainen3-0/+59
Add a __nonnnull__ attribute to std::string's _CharT* constructor * include/bits/basic_string.h (string(_CharT*, const _Alloc&)): Add a __nonnull__ attribute. * testsuite/21_strings/basic_string/cons/char/nonnull.cc: New. * testsuite/21_strings/basic_string/cons/wchar_t/nonnull.cc: Likewise.
2020-06-29PR libstdc++/95915Ville Voutilainen15-18/+92
PR libstdc++/95915 * include/std/type_traits (is_literal_type, is_literal_type_v): Deprecate in C++17. * include/std/variant (_Uninitialized): Adjust the condition and the comment. * testsuite/20_util/is_literal_type/deprecated-1z.cc: New. * testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc: Adjust. * testsuite/20_util/is_literal_type/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_literal_type/value.cc: Likewise. * testsuite/20_util/optional/constexpr/nullopt.cc: Use __is_literal_type directly. * testsuite/20_util/optional/nullopt.cc: Likewise. * testsuite/20_util/variable_templates_for_traits.cc: Adjust. * testsuite/20_util/variant/95915.cc: New. * testsuite/20_util/variant/compile.cc: Add new test. * testsuite/experimental/optional/constexpr/nullopt.cc: Use __is_literal_type directly. * testsuite/experimental/optional/nullopt.cc: Likewise. * testsuite/experimental/type_traits/value.cc: Adjust. * testsuite/util/testsuite_common_types.h: Use __is_literal_type directly.
2020-06-25Daily bump.GCC Administrator1-0/+20
2020-06-24libstdc++: Fix std::from_chars to ignore leading zeros in base 2Jonathan Wakely3-7/+99
The parser for binary numbers returned an error if the entire string contains more digits than the result type. Leading zeros should be ignored. libstdc++-v3/ChangeLog: * include/std/charconv (__from_chars_binary): Ignore leading zeros. * testsuite/20_util/from_chars/1.cc: Check "0x1" for all bases, not just 10 and 16. * testsuite/20_util/from_chars/3.cc: New test.
2020-06-24libstdc++: Fix warnings with -Wsystem-headersJonathan Wakely2-1/+4
libstdc++-v3/ChangeLog: * include/bits/stl_algobase.h (__find_if): Add FALLTHRU markers. * include/std/charconv (__detail::__to_chars): Avoid -Wsign-compare warning.
2020-06-24libstdc++: Fix std::to_chars buffer overflow (PR 95851)Jonathan Wakely2-1/+40
The __detail::__to_chars_2 function assumes it won't be called with zero values. However, when the output buffer is empty the caller doesn't handle zero values correctly, and calls __to_chars_2 with a zero value, resulting in an overflow of the empty buffer. The __detail::__to_chars_i function should just return immediately for an empty buffer, and otherwise ensure zero values are handled properly. libstdc++-v3/ChangeLog: PR libstdc++/95851 * include/std/charconv (__to_chars_i): Check for zero-sized buffer unconditionally. * testsuite/20_util/to_chars/95851.cc: New test.
2020-06-24Daily bump.GCC Administrator1-0/+30
2020-06-23libstdc++: Adjust std::from_chars negative testsJonathan Wakely2-1/+10
Also test with an enumeration type. Move the dg-error directives outside the #if block, because DejaGnu would process them whether or not wchar_t support is present. libstdc++-v3/ChangeLog: * testsuite/20_util/from_chars/1_c++20_neg.cc: Check enumeration type. * testsuite/20_util/from_chars/1_neg.cc: Likewise. Move dg-error directives outside preprocessor condition.
2020-06-23libstdc++: Implement P1972R2 changes to std::variant (PR 95832)Jonathan Wakely3-16/+44
G++ implements P1972R2 since r11-1597-0ca22d027ecc and so we no longer need the P0608R3 special case to prevent narrowing conversions to bool. Since non-GNU compilers don't necessarily implment P1972R2 yet, this may cause a regression for those compilers. There is no feature-test macro we can use to detect it though, so we'll have to live with it. libstdc++-v3/ChangeLog: PR libstdc++/95832 * include/std/variant (__detail::__variant::_Build_FUN): Remove partial specialization to prevent narrowing conversions to bool. * testsuite/20_util/variant/compile.cc: Test non-narrowing conversions to bool. * testsuite/20_util/variant/run.cc: Likewise.
2020-06-23libstdc++: Regenerate makefilesJonathan Wakely11-0/+11
libstdc++-v3/ChangeLog: * doc/Makefile.in: Regenerate. * include/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate.
2020-06-23Daily bump.GCC Administrator1-0/+5
2020-06-22build: Use -include instead of conditional include.David Edelsohn2-6/+2
Automake and GNU Make both use the endif keyword, which conflicts and elicits an error for matching if/ifdef and endif. This patch changes the conditional include to use "-include" to prevent a warning about a possible empty tmake_file. libgomp/ChangeLog 2020-06-22 David Edelsohn <dje.gcc@gmail.com> * Makefile.am: Use -include. * Makefile.in: Regenerate. libatomic/ChangeLog 2020-06-22 David Edelsohn <dje.gcc@gmail.com> * Makefile.am: Use -include. * Makefile.in: Regenerate. libstdc++-v3/ChangeLog 2020-06-22 David Edelsohn <dje.gcc@gmail.com> * Makefile.am: Use -include. * Makefile.in: Regenerate. libgfortran/ChangeLog 2020-06-22 David Edelsohn <dje.gcc@gmail.com> * Makefile.am: Use -include. * Makefile.in: Regenerate.
2020-06-22Daily bump.GCC Administrator1-0/+9
2020-06-21aix: Add GCC64 configuration and FAT target libraries.David Edelsohn6-20/+57
This patch adds the ability to configure GCC on AIX to build as a 64 bit application and to build target libraries "FAT" libraries in both 32 bit and 64 bit mode. The patch adds makefile fragment hooks to target libraries that allows them to include target-specific rules. The target specific rules for AIX place both 32 bit and 64 bit objects and shared objects in archives at the top-level, not multilib subdirectories. The multilibs are built in subdirectories, but must be combined during the last parts of the target library build process. Because of the way that GCC bootstrap works, the libraries must be combined during the multiple stages of GCC bootstrap, not solely when installed in the final destination, so the libraries are correct at the end of each target library build stage, not solely an install recipe. gcc/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * config.gcc: Use t-aix64, biarch64 and default64 for cpu_is_64bit. * config/rs6000/aix72.h (ASM_SPEC): Remove aix64 option. (ASM_SPEC32): New. (ASM_SPEC64): New. (ASM_CPU_SPEC): Remove vsx and altivec options. (CPP_SPEC_COMMON): Rename from CPP_SPEC. (CPP_SPEC32): New. (CPP_SPEC64): New. (CPLUSPLUS_CPP_SPEC): Rename to CPLUSPLUS_CPP_SPEC_COMMON.. (TARGET_DEFAULT): Only define if not BIARCH. (LIB_SPEC_COMMON): Rename from LIB_SPEC. (LIB_SPEC32): New. (LIB_SPEC64): New. (LINK_SPEC_COMMON): Rename from LINK_SPEC. (LINK_SPEC32): New. (LINK_SPEC64): New. (STARTFILE_SPEC): Add 64 bit version of crtcxa and crtdbase. (ASM_SPEC): Define 32 and 64 bit alternatives using DEFAULT_ARCH64_P. (CPP_SPEC): Same. (CPLUSPLUS_CPP_SPEC): Same. (LIB_SPEC): Same. (LINK_SPEC): Same. (SUBTARGET_EXTRA_SPECS): Add new 32/64 specs. * config/rs6000/defaultaix64.h: New file. * config/rs6000/t-aix64: New file. libgcc/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * config.host (extra_parts): Add crtcxa_64 and crtdbase_64. * config/rs6000/t-aix-cxa: Explicitly compile 32 bit with -maix32 and 64 bit with -maix64. * config/rs6000/t-slibgcc-aix: Remove extra @multilib_dir@ level. Build and install AIX-style FAT libraries. libgomp/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * Makefile.am (tmake_file): Build and install AIX-style FAT libraries. * Makefile.in: Regenerate * configure.ac (tmake_file): Substitute. * configure: Regenerate. * configure.tgt (powerpc-ibm-aix*): Define tmake_file. * config/t-aix: New file. libstdc++-v3/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * Makefile.am (tmake_file): Build and install AIX-style FAT libraries. * Makefile.in: Regenerate. * configure.ac (tmake_file): Substitute. * configure: Regenerate. * configure.host (aix*): Define tmake_file. * config/os/aix/t-aix: New file. libatomic/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * Makefile.am (tmake_file): Build and install AIX-style FAT libraries. * Makefile.in: Regenerate. * configure.ac (tmake_file): Substitute. * configure: Regenerate. * configure.tgt (powerpc-ibm-aix*): Define tmake_file. * config/t-aix: New file. libgfortran/ChangeLog 2020-06-21 David Edelsohn <dje.gcc@gmail.com> * Makefile.am (tmake_file): Build and install AIX-style FAT libraries. * Makefile.in: Regenerate. * configure.ac (tmake_file): Substitute. * configure: Regenerate. * configure.host: Add system configury stanza. Define tmake_file. * config/t-aix: New file.
2020-06-21Daily bump.GCC Administrator1-0/+7
2020-06-20c++: Refinements to "more constrained".Jason Merrill2-41/+0
P2113 from the last C++ meeting clarified that we only compare constraints on functions or function templates that have equivalent template parameters and function parameters. I'm not currently implementing the complicated handling of reversed comparison operators here; thinking about it now, it seems like a lot of complexity to support a very weird usage. If I write two similar comparison operators to be distinguished by their constraints, why would I write one reversed? If they're two unrelated operators, they're very unlikely to be similar enough for the complexity to help. I've started a discussion on the committee reflector about changing these rules. This change breaks some greedy_ops tests in libstdc++ that were relying on comparing constraints on unrelated templates, which seems pretty clearly wrong, so I'm removing those tests for now. gcc/cp/ChangeLog: * call.c (joust): Only compare constraints for non-template candidates with matching parameters. * pt.c (tsubst_pack_expansion): Fix getting a type parameter pack. (more_specialized_fn): Only compare constraints for candidates with matching parameters. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-return-req1.C: Expect error. * g++.dg/cpp2a/concepts-p2113a.C: New test. * g++.dg/cpp2a/concepts-p2113b.C: New test. libstdc++-v3/ChangeLog: * testsuite/24_iterators/move_iterator/rel_ops_c++20.cc: Remove greedy_ops tests. * testsuite/24_iterators/reverse_iterator/rel_ops_c++20.cc: Remove greedy_ops tests.
2020-06-20Daily bump.GCC Administrator1-0/+36
2020-06-19libstdc++: Fix some -Wsystem-headers warnings (PR 95765)Jonathan Wakely2-7/+4
PR libstdc++/95765 * include/bits/stl_algobase.h (__size_to_integer(float)) (__size_to_integer(double), __size_to_integer(long double)) (__size_to_integer(__float128)): Cast return type explicitly. * include/bits/stl_uninitialized.h (__uninitialized_default_1<true>): Remove unused typedef.
2020-06-19libstdc++: Remove redundant std:: qualificationJonathan Wakely3-79/+79
* include/bits/stl_pair.h (_Index_tuple): Remove redundant namespace qualification. (pair::pair(tuple<>&, tuple<>&, _Index_tuple, _Index_tuple)): Likewise. * include/std/tuple (_Head_base, _Tuple_impl, tuple_size) (tuple_element, __get_helper, get, __make_tuple_impl) (__make_1st_indices, __tuple_concater) (pair::pair(tuple<>&, tuple<>&, _Index_tuple, _Index_tuple)): Likewise. * include/std/utility (tuple_element, __is_tuple_like_impl) (tuple_size, __pair_get, get): Likewise.
2020-06-19libstdc++: Define all std::function members inlineJonathan Wakely1-94/+65
* include/bits/std_function.h (function): Define all member functions inline.
2020-06-19libstdc++: std::includes performance tweakMarc Glisse1-8/+6
A small tweak to the implementation of __includes, which in my application saves 20% of the running time. I noticed it because using range-v3 was giving unexpected performance gains. Some of the gain comes from pulling the 2 calls ++__first1 out of the condition so there is just one call. And most of the gain comes from replacing the resulting if (__comp(__first1, __first2)) ; else ++__first2; with if (!__comp(__first1, __first2)) ++__first2; I was very surprised that the code ended up being so different for such a change, and I still don't really understand where the extra time is going... Anyway, while I blame the compiler for not generating very good code with the current implementation, I believe the change can be seen as a simplification. libstdc++-v3/ChangeLog: * include/bits/stl_algo.h (__includes): Simplify the code.
2020-06-19libstdc++: Optimize std::optional default constructorMarc Glisse1-1/+1
The attached patch changes the code generated for std::optional<std::array<int,1024>>f(){return{};} from movq $0, (%rdi) movq %rdi, %r8 leaq 8(%rdi), %rdi xorl %eax, %eax movq $0, 4084(%rdi) movq %r8, %rcx andq $-8, %rdi subq %rdi, %rcx addl $4100, %ecx shrl $3, %ecx rep stosq movq %r8, %rax or with different tuning subq $8, %rsp movl $4100, %edx xorl %esi, %esi call memset addq $8, %rsp to the much shorter movb $0, 4096(%rdi) movq %rdi, %rax i.e. the same as the nullopt constructor. The constructor was already non-trivial, so we don't lose that. It passes the testsuite without regression, but there is no new testcase to verify the better codegen. libstdc++-v3/ChangeLog: * include/std/optional (optional()): Explicitly define it.
2020-06-18Daily bump.GCC Administrator1-0/+36
2020-06-17libstdc++: Avoid stack overflow in std::vector (PR 94540)Jonathan Wakely6-16/+200
The std::__uninitialized_default_n algorithm used by std::vector creates an initial object as a local variable then copies that into the destination range. If the object is too large for the stack this crashes. We should create the first object directly into the destination and then copy it from there. This doesn't fix the bug for C++98, because in that case the initial value is created as a default argument of the vector constructor i.e. in the user's code, not inside libstdc++. We can't prevent that. PR libstdc++/94540 * include/bits/stl_uninitialized.h (__uninitialized_default_1<true>): Construct the first value at *__first instead of on the stack. (__uninitialized_default_n_1<true>): Likewise. Improve comments on several of the non-standard algorithms. * testsuite/20_util/specialized_algorithms/uninitialized_default/94540.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_default_n/94540.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94540.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/94540.cc: New test. * testsuite/23_containers/vector/cons/94540.cc: New test.
2020-06-17libstdc++: Fix tests for uninitialized_value_construct_nJonathan Wakely2-46/+12
In my recent r11-1460 commit the tests had been "improved" before commit, and no longer exercised the code paths changed by the patch. This restores what I originally tested, so that the tests fail before the r11-1460 change and pass after it. * testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc: Replace Value type with int so trivial code path is used. * testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc: Likewise.
2020-06-17libstdc++: Handle non-integral sizes in std::uninitialized_fill_nJonathan Wakely4-9/+224
The std::uninitialized_fill_n algorithm uses sd::fill_n for trivial types, but that algorithm has a stronger requirement that the Size parameter is convertible to an integral type. As the new test shows, there are types which are valid for std::uninitialized_fill_n but which produce a different result when converted to an integral type, or cannot be converted at all. Only use the std::fill_n optimization when the Size type is already an integral type. The std::__uninitialized_default_n extension has the same problem, and so does C++17's std::uninitialized_value_construct_n which uses it. * include/bits/stl_uninitialized.h (uninitialized_fill_n): Only use std::fill_n when the size is an integral type. (__uninitialized_default_n): Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_fill_n/sizes.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc: New test.
2020-06-17Daily bump.GCC Administrator1-0/+18
2020-06-16libstdc++: Strip cv-qualifiers in std::atomic<FP> (PR 95282)Jonathan Wakely1-5/+5
This improves the previous fix for PR 95282, and extends it to also apply to the exchange function (which has a similar problem and would become ill-formed with my proposed fix for PR 95378). PR libstdc++/95282 * include/bits/atomic_base.h (__atomic_impl::load): Use the _Val alias instead of deducing _Tp as an unqualified type. (__atomic_impl::exchange): Use the _Val alias to remove volatile from the reinterpret_cast result type.
2020-06-16libstdc++: Enforce copyable/movable checks in std::atomicJonathan Wakely2-0/+50
C++20 adds some new preconditions to std::atomic, which weren't previously checked by our implementation. * include/std/atomic (atomic): Add static assertions. * testsuite/29_atomics/atomic/requirements/types_neg.cc: New test.
2020-06-16c++: Improve access checking inside templates [PR41437]Patrick Palka1-0/+28
This patch generalizes our existing functionality for deferring access checking of typedefs when parsing a function or class template to now defer all kinds of access checks until template instantiation time, including member function and member object accesses. Since all access checks eventually go through enforce_access, the main component of this patch is new handling inside enforce_access to defer the current access check if we're inside a template. The bulk of the rest of the patch consists of removing now-unneeded code pertaining to suppressing access checks inside templates or pertaining to typedef-specific access handling. Renamings and other changes with no functional impact have been split off into the followup patch. gcc/cp/ChangeLog: PR c++/41437 PR c++/47346 * call.c (enforce_access): Move to semantics.c. * cp-tree.h (enforce_access): Delete. (get_types_needing_access_check): Delete. (add_typedef_to_current_template_for_access_check): Delete. * decl.c (make_typename_type): Adjust accordingly. Use check_accessibility_of_qualified_id instead of directly using perform_or_defer_access_check. * parser.c (cp_parser_template_declaration_after_parameters): Don't push a dk_no_check access state when parsing a template. * pt.c (get_types_needing_access_check): Delete. (append_type_to_template_for_access_check_1): Delete. (perform_typedefs_access_check): Adjust. If type_decl is a FIELD_DECL, also check its DECL_CONTEXT for dependence. Use tsubst_copy instead of tsubst to substitute into type_decl so that we substitute into the DECL_CONTEXT of a FIELD_DECL. (append_type_to_template_for_access_check): Delete. * search.c (accessible_p): Remove the processing_template_decl early exit. * semantics.c (enforce_access): Moved from call.c. If we're parsing a template and the access check failed, add the check to TI_TYPEDEFS_NEEDING_ACCESS_CHECKING. (perform_or_defer_access_check): Adjust comment. (add_typedef_to_current_template_for_access_check): Delete. (check_accessibility_of_qualified_id): Adjust accordingly. Exit early if the scope is dependent. gcc/testsuite/ChangeLog: PR c++/41437 PR c++/47346 * g++.dg/cpp2a/concepts-using2.C: Adjust. * g++.dg/lto/20081219_1.C: Adjust. * g++.dg/lto/20091002-1_0.C: Adjust. * g++.dg/lto/pr65475c_0.C: Adjust. * g++.dg/opt/dump1.C: Adjust. * g++.dg/other/pr53574.C: Adjust. * g++.dg/template/access30.C: New test. * g++.dg/template/access31.C: New test. * g++.dg/wrappers/wrapper-around-type-pack-expansion.C: Adjust. libstdc++-v3/ChangeLog: PR libstdc++/94003 * testsuite/20_util/is_constructible/94003.cc: New test.
2020-06-16Daily bump.GCC Administrator1-0/+17
2020-06-15libstdc++: Update value of __cpp_lib_constexpr_char_traits for C++20Jonathan Wakely4-5/+16
Although not required by SD-6 or the C++20 draft, we define the macro __cpp_lib_constexpr_char_traits to indicate support for P0432R1. This updates the value in C++20 mode for the P1032R1 changes to char_traits. * include/bits/char_traits.h (__cpp_lib_constexpr_char_traits): Update value for C++20. * include/std/version (__cpp_lib_constexpr_char_traits): Likewise. * testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc: Update expected value. * testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc: Likewise.
2020-06-15libstdc++: Fix char_traits move with overlapPaul Keir2-1/+53
Upon constexpr evaluation, char_traits move uses copy_backward, but its last argument should be to the range end rather than its beginning. 2020-06-12 Paul Keir <paul.keir@uws.ac.uk> * include/bits/char_traits.h (char_traits::move): constexpr move with overlap was using copy_backward incorrectly. * testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc: New test.
2020-06-13Daily bump.GCC Administrator1-0/+17
2020-06-12libstdc++: Improve tests for std::atomic_flagJonathan Wakely3-12/+10
The tests for clear() and test_and_set() didn't cover all cases. * testsuite/29_atomics/atomic_flag/clear/1.cc: Also test clear() when the value is currently set. * testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc: Actually check the return value. * testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc: Likewise.
2020-06-12libstdc++: Make std::atomic_flag::test members constJonathan Wakely3-10/+26
Also fix the tests so they run without an explicit -std=gnu++2a in the RUNTESTFLAGS, and test the new function on const-qualified objects. * include/bits/atomic_base.h (atomic_flag::test): Add missing const qualifiers. * testsuite/29_atomics/atomic_flag/test/explicit.cc: Add dg-options and verify results of test function. * testsuite/29_atomics/atomic_flag/test/implicit.cc: Likewise.
2020-06-12Daily bump.GCC Administrator1-0/+11
2020-06-11libstdc++: Fix istream::ignore discarding too many chars (PR 94749)Jonathan Wakely4-12/+158
The current code assumes that if the next character in the stream is equal to the delimiter then we stopped because we saw that delimiter, and so discards it. But in the testcase for the PR we stop because we reached the maximum number of characters, and it's coincidence that the next character equals the delimiter. We should not discard the next character in that case. The fix is to check that we haven't discarded __n characters already, instead of checking whether the next character equals __delim. Because we've already checked for EOF, if we haven't discarded __n yet then we know we stopped because we saw the delimiter. On the other hand, if the next character is the delimiter we don't know if that's why we stopped. PR libstdc++/94749 * include/bits/istream.tcc (basic_istream::ignore(streamsize, CharT)): Only discard an extra character if we didn't already reach the maximum number. * src/c++98/istream.cc (istream::ignore(streamsiz, char)) (wistream::ignore(streamsize, wchar_t)): Likewise. * testsuite/27_io/basic_istream/ignore/char/94749.cc: New test. * testsuite/27_io/basic_istream/ignore/wchar_t/94749.cc: New test.
2020-06-11Daily bump.GCC Administrator1-0/+49
2020-06-10libstdc++: Fix some ranges algos optimizations [PR95578]Patrick Palka8-45/+465
ranges::copy and a number of other ranges algorithms have unwrapping optimizations for iterators of type __normal_iterator, move_iterator and reverse_iterator. But in the checks that guard these optimizations we currently only test that the iterator of the iterator/sentinel pair has the appropriate type before proceeding with the corresponding optimization, and do not also test the sentinel type. This breaks the testcase in this PR because this testcase constructs via range adaptors a range whose begin() is a __normal_iterator and whose end() is a custom sentinel type, and then performs ranges::copy on it. From there we bogusly perform the __normal_iterator unwrapping optimization on this iterator/sentinel pair, which immediately leads to a constraint failure since the custom sentinel type does not model sentinel_for<int*>. This patch fixes this issue by refining each of the problematic checks to also test that the iterator and sentinel types are the same before applying the corresponding unwrapping optimization. Along the way, some code simplifications are made. libstdc++-v3/ChangeLog: PR libstdc++/95578 * include/bits/ranges_algo.h (__lexicographical_compare_fn): Also check that the iterator and sentinel have the same type before applying the unwrapping optimization for __normal_iterator. Split the check into two, one for the first iterator/sentinel pair and another for second iterator/sentinel pair. Remove uses of __niter_base, and remove uses of std::move on a __normal_iterator. * include/bits/ranges_algobase.h (__equal_fn): Likewise. (__copy_or_move): Likewise. Perform similar adjustments for the reverse_iterator and move_iterator optimizations. Inline the checks into the if-constexprs, and use using-declarations to make them less visually noisy. Remove uses of __niter_wrap. (__copy_or_move_backward): Likewise. * testsuite/25_algorithms/copy/95578.cc: New test. * testsuite/25_algorithms/copy_backward/95578.cc: New test. * testsuite/25_algorithms/equal/95578.cc: New test. * testsuite/25_algorithms/lexicographical_compare/95578.cc: New test. * testsuite/25_algorithms/move/95578.cc: New test. * testsuite/25_algorithms/move_backward/95578.cc: New test.
2020-06-10libstdc++: Extend memcmp optimization in std::lexicographical_compareFrançois Dumont5-18/+606
Make the memcmp optimization work for std::deque iterators and safe iterators. Co-authored-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: 2020-06-08 François Dumont <fdumont@gcc.gnu.org> Jonathan Wakely <jwakely@redhat.com> * include/bits/deque.tcc (__lex_cmp_dit): New. (__lexicographical_compare_aux1): Define overloads for deque iterators. * include/bits/stl_algobase.h (__lexicographical_compare::__3way): New static member function. (__lexicographical_compare<true>::__3way): Likewise. (__lexicographical_compare<true>::__lc): Use __3way. (__lexicographical_compare_aux): Rename to __lexicographical_compare_aux1 and declare overloads for deque iterators. (__lexicographical_compare_aux): Define new forwarding function that calls __lexicographical_compare_aux1 and declare new overloads for safe iterators. (lexicographical_compare): Do not use __niter_base on parameters. * include/debug/safe_iterator.tcc (__lexicographical_compare_aux): Define overloads for safe iterators. * testsuite/25_algorithms/lexicographical_compare/1.cc: Add checks with random access iterators. * testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc: New test.
2020-06-10Daily bump.GCC Administrator1-0/+11
2020-06-09libstdc++: Define converting assignment operator for std::move_iteratorJonathan Wakely2-0/+59
As clarified by LWG 3265, std::move_iterator is supposed to have an assignment operator that converts from a different specialization of std::move_iterator, which performs an assignment. That has always been missing from libstdc++, so assigning a different type actually performs a converting construction, then an assignment. This is non-conforming for the (fairly contrived) case where the converting assignment is well-formed but the converting construction is not. * include/bits/stl_iterator.h (move_iterator::operator=): Define. * testsuite/24_iterators/move_iterator/dr3265.cc: New test.
2020-06-09libstdc++: Define std::bad_optional_access constructor as defaultedJonathan Wakely2-4/+30
The standard requires that std::bad_optional_access' default constructor has a non-throwing exception specification. * include/std/optional (bad_optional_access): Define default constructor and destructor as defaulted. * testsuite/20_util/optional/bad_access.cc: New test.
2020-06-09Daily bump.GCC Administrator1-0/+11
2020-06-08libstdc++: Fix failing testsJonathan Wakely2-2/+2
These started failing with the previous commit, because I forgot to add the tests after adjusting them. * testsuite/20_util/default_delete/48631_neg.cc: Adjust dg-error line number. * testsuite/20_util/default_delete/void_neg.cc: Likewise.
2020-06-08libstdc++: Implement operator<< for std::unique_ptr (LWG 2948)Jonathan Wakely2-2/+109
libstdc++-v3/ChangeLog: * include/bits/unique_ptr.h (operator<<): Define for C++20. * testsuite/20_util/unique_ptr/io/lwg2948.cc: New test.
2020-06-05Daily bump.GCC Administrator1-0/+55