Commit Graph

185351 Commits

Author SHA1 Message Date
Jonathan Wakely
9ef31bab15 libstdc++: Fix dangling string_view in filesystem::path [PR102592]
When creating a path from a pair of non-contiguous iterators we pass the
iterators to _S_convert(Iter, Iter). That function passes the iterators
to __string_from_range to get a contiguous sequence of characters, and
then calls _S_convert(const C*, const C*) to perform the encoding
conversions. If the value type, C, is char8_t, then no conversion is
needed and the _S_convert<char8_t>(const char8_t*, const char8_t*)
specialization casts the pointer to const char* and returns a
std::string_view that refs to the char8_t sequence. However, that
sequence is owned by the std::u8string rvalue returned by
__string_from_range, which goes out of scope when _S_convert(Iter, Iter)
returns. That means the std::string_view is dangling and we get
undefined behaviour when parsing it as a path.

The same problem does not exist for the path members taking a "Source"
argument, because those functions all convert a non-contiguous range
into a basic_string<C> immediately, using __effective_range(__source).
That means that the rvalue string returned by that function is still in
scope for the full expression, so the string_view does not dangle.

The solution for the buggy functions is to do the same thing, and call
__string_from_range immediately, so that the returned rvalue is still in
scope for the lifetime of the string_view returned by _S_convert. To
avoid reintroducing the same problem, remove the _S_convert(Iter, Iter)
overload that calls __string_from_range and returns a dangling view.

libstdc++-v3/ChangeLog:

	PR libstdc++/102592
	* include/bits/fs_path.h (path::path(Iter, Iter, format))
	(path::append(Iter, Iter), path::concat(Iter, Iter)): Call
	__string_from_range directly, instead of two-argument overload
	of _S_convert.
	(path::_S_convert(Iter, Iter)): Remove.
	* testsuite/27_io/filesystem/path/construct/102592.C: New test.

(cherry picked from commit 85b24e32dc)
2021-10-13 21:54:20 +01:00
Jonathan Wakely
3eac45a2a1 libstdc++: Add noexcept-specifier to basic_string_view(It, End)
This adds a conditional noexcept to the C++20 constructor. The
std::to_address call cannot throw, so only taking the difference of the
two iterators can throw.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/string_view (basic_string_view(It, End)): Add
	noexcept-specifier.
	* testsuite/21_strings/basic_string_view/cons/char/range.cc:
	Check noexcept-specifier. Also check construction without CTAD.

(cherry picked from commit f9c2ce1dae)
2021-10-13 21:54:20 +01:00
Iain Sandoe
8b333df948 Darwin, X86, config: Adjust 'as' command lines [PR100340].
Versions of the assembler using clang from XCode 12.5/12.5.1
have a bug which produces different code layout between debug and
non-debug input, leading to a compare fail for default configure
parameters.

This is a workaround fix to disable the optimisation that is
responsible for the bug.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

PR target/100340 - Bootstrap fails with Clang 12.0.5 (XCode 12.5)

	PR target/100340

gcc/ChangeLog:

	* config.in: Regenerate.
	* config/i386/darwin.h (EXTRA_ASM_OPTS): New
	(ASM_SPEC): Pass options to disable branch shortening where
	needed.
	* configure: Regenerate.
	* configure.ac: Detect versions of 'as' that support the
	optimisation which has the bug.

(cherry picked from commit 743b8dd6fd)
2021-10-13 20:59:03 +01:00
John David Anglin
b707ac10d5 Add support for 32-bit hppa targets in muldi3 expander
2021-10-13  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

	* config/pa/pa.md (muldi3): Add support for inlining 64-bit
	multiplication on 32-bit PA 1.1 and 2.0 targets.
2021-10-13 15:45:39 +00:00
Patrick Palka
cb261f0e8f libstdc++: Fix various bugs in ranges_algo.h [PR100187, ...]
This fixes some bugs with our ranges algorithms in uncommon situations,
such as when the return type of a predicate is a non-copyable class type
that's implicitly convertible to bool (PR100187), when a comparison
predicate isn't invocable as an rvalue (PR100237), and when the return
type of a projection function is non-copyable (PR100249).

This also fixes PR100287, which reports that we're moving __first twice
when constructing with it an empty subrange in ranges::partition.

libstdc++-v3/ChangeLog:

	PR libstdc++/100187
	PR libstdc++/100237
	PR libstdc++/100249
	PR libstdc++/100287
	* include/bits/ranges_algo.h (__search_n_fn::operator()): Give
	the __value_comp lambda an explicit bool return type.
	(__is_permutation_fn::operator()): Give the __proj_scan local
	variable auto&& return type.  Give the __comp_scan lambda an
	explicit bool return type.
	(__remove_fn::operator()): Give the __pred lambda an explicit
	bool return type.
	(__partition_fn::operator()): Don't std::move __first twice
	when returning an empty subrange.
	(__min_fn::operator()): Don't std::move __comp.
	(__max_fn::operator()): Likewise.
	(__minmax_fn::operator()): Likewise.

(cherry picked from commit d91e7eab3a)
2021-10-13 09:32:37 -04:00
Iain Sandoe
28f91cc71b Darwin, D: Fix bootstrap when target does not support -Bstatic/dynamic.
This fixes a bootstrap fail because saw_static_libcxx was unused for
targets without support for -Bstatic/dynamic.

The fix applied pushes the -static-libstdc++ back onto the command
line, which allows a target to substitute a static version of the
c++ standard library using specs.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/d/ChangeLog:

	* d-spec.cc (lang_specific_driver): Push the -static-libstdc++
	option back onto the command line for targets without support
	for -Bstatic/dynamic.

(cherry picked from commit e24760533b)
2021-10-13 10:02:04 +01:00
GCC Administrator
5f88afa1a2 Daily bump. 2021-10-13 00:18:09 +00:00
Jonathan Wakely
6d51766a55 libstdc++: Fix ip::tcp::resolver test failure on Solaris
Solaris 11 does not have "http" in /etc/services, which causes this test
to fail. Try some other services until we find one that works.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/experimental/net/internet/resolver/ops/lookup.cc:
	Try other service if "http" fails.

(cherry picked from commit 48b20d46f9)
2021-10-12 20:40:38 +01:00
Jonathan Wakely
b7e73951fd libstdc++: Make Networking TS headers more portable [PR100285]
Add more preprocessor conditions to check for constants being defined
before using them, so that the Networking TS headers can be compiled on
a wider range of platforms.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/100285
	* configure.ac: Check for O_NONBLOCK.
	* configure: Regenerate.
	* include/experimental/internet: Include <ws2tcpip.h> for
	Windows.  Use preprocessor conditions around more constants.
	* include/experimental/socket: Use preprocessor conditions
	around more constants.
	* testsuite/experimental/net/internet/resolver/base.cc: Only use
	constants when the corresponding C macro is defined.
	* testsuite/experimental/net/socket/basic_socket.cc: Likewise.
	* testsuite/experimental/net/socket/socket_base.cc: Likewise.
	Make preprocessor checks more fine-grained.
2021-10-12 20:40:37 +01:00
Jonathan Wakely
10c0df1048 libstdc++: fix is_default_constructible for hash containers [PR 100863]
The recent change to _Hashtable_ebo_helper for this PR broke the
is_default_constructible trait for a hash container with a non-default
constructible allocator. That happens because the constructor needs to
be user-provided in order to initialize the member, and so is not
defined as deleted when the type is not default constructible.

By making _Hashtable derive from _Enable_special_members we can ensure
that the default constructor for the std::unordered_xxx containers is
deleted when it would be ill-formed. This makes the trait give the
correct answer.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/100863
	* include/bits/hashtable.h (_Hashtable): Conditionally delete
	default constructor by deriving from _Enable_special_members.
	* testsuite/23_containers/unordered_map/cons/default.cc: New test.
	* testsuite/23_containers/unordered_set/cons/default.cc: New test.

(cherry picked from commit 89ec3b67db)
2021-10-12 20:40:37 +01:00
Jonathan Wakely
573c2ffd3c libstdc++: Value-initialize objects held by EBO helpers [PR 100863]
The allocator, hash function and equality function should all be
value-initialized by the default constructor of an unordered container.
Do it in the EBO helper, so we don't have to get it right in multiple
places.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/100863
	PR libstdc++/65816
	* include/bits/hashtable_policy.h (_Hashtable_ebo_helper):
	Value-initialize subobject.
	* testsuite/23_containers/unordered_map/allocator/default_init.cc:
	Remove XFAIL.
	* testsuite/23_containers/unordered_set/allocator/default_init.cc:
	Remove XFAIL.

(cherry picked from commit f8f0193b5b)
2021-10-12 20:40:37 +01:00
Jonathan Wakely
4407f0d739 libstdc++: Allow lualatex to be used for Doxygen PDF
This allows the Doxygen PDF to be built using lualatex instead of
pdflatex, which solves a problem with pdflatex running out of memory
sometimes. This is done by adding a --latex_cmd option to the
run_doxygen script, which then sets the specified command in the
generated user.cfg file used by Doxygen. The makefile is adjusted to
pass --latex_cmd=$(LATEX_CMD) to the script, so using running make with
LATEX_CMD=lualatex will override the default.

Additionally, this does some refactoring of the doc/Makefile.am rules
and the run_doxygen script.

libstdc++-v3/ChangeLog:

	* doc/Makefile.am: Simplify doxygen recipes and use --latex_cmd.
	* doc/Makefile.in: Regenerate.
	* doc/doxygen/user.cfg.in (LATEX_CMD_NAME): Add placeholder
	value.
	* scripts/run_doxygen (print_usage): Always print to stdout and
	do not exit.
	(fail): New function for exiting on error.
	(parse_options): Handle --latex_cmd. Do not treat --help the
	same as errors. Simplify handling of required arguments.

(cherry picked from commit e3b6d3a887)
2021-10-12 20:40:37 +01:00
Jonathan Wakely
496f712946 libstdc++: Reduce output of 'make doc-pdf-doxygen'
Use '@' to prevent Make from echoing the recipe, so that users don't see
this every time:

  if [ -f ${doxygen_pdf} ]; then
    mv ${doxygen_pdf} ${api_pdf} ;
    echo ":: PDF file is ${api_pdf}";
  else
    echo "... error";
    grep -F 'LaTeX Error' ${doxygen_outdir}/latex/refman.log;
    grep -F 'TeX capacity exceeded, sorry' ${doxygen_outdir}/latex/refman.log;
    exit 12;
  fi

The presence of the "error" strings in the output makes it look like an
error happened. By suppressing the echoing user's will only see "error"
if the 'else' branch is taken.

libstdc++-v3/ChangeLog:

	* doc/Makefile.am (stamp-pdf-doxygen): Improve comment about
	dealing with errors. Use '@' to prevent shell command being
	echoed.
	* doc/Makefile.in: Regenerate.

(cherry picked from commit 43a35b26e2)
2021-10-12 20:40:37 +01:00
Jonathan Wakely
bf0c732dd5 libstdc++: Add warnings for some C++23 deprecations
LWG 3036 deprecates std::pmr::polymorphic_allocator<T>::destroy in
favour of the equivalent member of std::allocator_traits.

LWG 3170 deprecates std::allocator<T>::is_always_equal in favour of
the equivalent member of std::allocator_traits.

This also updates a comment to note that we support the LWG 3541 change
(even before the issue was opened).

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/allocator.h (allocator::is_always_equal): Deprecate.
	* include/bits/iterator_concepts.h (indirectly_readable_traits):
	Add LWG issue number to comment.
	* include/std/memory_resource (polymorphic_allocator::release):
	Deprecate.
	* testsuite/20_util/allocator/requirements/typedefs.cc: Add
	dg-warning for deprecation. Also check std::allocator<void>.

(cherry picked from commit 5bfcfe3087)
2021-10-12 20:40:37 +01:00
Jonathan Wakely
f8e3747891 libstdc++: Fix 17_intro/names.cc failures on Solaris
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc: Undefine some more names used
	by Solaris system headers.

(cherry picked from commit 69b09c5599)
2021-10-12 20:40:36 +01:00
Jonathan Wakely
a1dc688940 libstdc++: Remove __gnu_cxx::rope::erase(size_type) [PR102048]
This function claims to remove a single character at index p, but it
actually removes p+1 characters beginning at p. So r.erase(0) removes
the first character, but r.erase(1) removes the second and third, and
r.erase(2) removes the second, third and fourth. This is not a useful
API.

The overload is present in the SGI STL <stl_rope.h> header that we
imported, but it isn't documented in the API reference. The erase
overloads that are documented are:

erase(const iterator& p)
erase(const iterator& f, const iterator& l)
erase(size_type i, size_type n);

Having an erase(size_type p) overload that erases a single character (as
the comment says it does) might be useful, but would be inconsistent
with std::basic_string::erase(size_type p = 0, size_type n = npos),
which erases from p to the end of the string when called with a single
argument.

Since the function isn't part of the documented API, doesn't do what it
claims to do (or anything useful) and "fixing" it would leave it
inconsistent with basic_string, I'm just removing that overload.

libstdc++-v3/ChangeLog:

	PR libstdc++/102048
	* include/ext/rope (rope::erase(size_type)): Remove broken
	function.

(cherry picked from commit 2cd229dec8)
2021-10-12 20:40:36 +01:00
Jonathan Wakely
cec047eaeb libstdc++: Skip filesystem tests that depend on permissions [PR90787]
Tests that depend on filesystem permissions FAIL if run on Windows or as
root. Add a helper function to detect those cases, so the tests can skip
those checks gracefully.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/90787
	* testsuite/27_io/filesystem/iterators/directory_iterator.cc:
	Use new __gnu_test::permissions_are_testable() function.
	* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/exists.cc: Likewise.
	* testsuite/27_io/filesystem/operations/is_empty.cc: Likewise.
	* testsuite/27_io/filesystem/operations/remove.cc: Likewise.
	* testsuite/27_io/filesystem/operations/remove_all.cc: Likewise.
	* testsuite/27_io/filesystem/operations/status.cc: Likewise.
	* testsuite/27_io/filesystem/operations/symlink_status.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/iterators/directory_iterator.cc:
	Likewise.
	* testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc:
	Likewise.
	* testsuite/experimental/filesystem/operations/exists.cc:
	Likewise.
	* testsuite/experimental/filesystem/operations/is_empty.cc:
	Likewise.
	* testsuite/experimental/filesystem/operations/remove.cc:
	Likewise.
	* testsuite/experimental/filesystem/operations/remove_all.cc:
	Likewise.
	* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
	Likewise.
	* testsuite/util/testsuite_fs.h (__gnu_test::permissions_are_testable):
	New function to guess whether testing permissions will work.

(cherry picked from commit 29b2fd371f)
2021-10-12 20:40:36 +01:00
Patrick Palka
e22db02874 libstdc++: Add missing std::move to ranges::copy/move/reverse_copy [PR101599]
In passing, this also renames the template parameter _O2 to _Out2 in
ranges::partition_copy and uglifies two of its function parameters,
out_true and out_false.

	PR libstdc++/101599

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__reverse_copy_fn::operator()):
	Add missing std::move in return statement.
	(__partition_copy_fn::operator()): Rename templtae parameter
	_O2 to _Out2.  Uglify function parameters out_true and out_false.
	* include/bits/ranges_algobase.h (__copy_or_move): Add missing
	std::move to recursive call that unwraps a __normal_iterator
	output iterator.
	* testsuite/25_algorithms/copy/constrained.cc (test06): New test.
	* testsuite/25_algorithms/move/constrained.cc (test05): New test.

(cherry picked from commit 14d8a5ae47)
2021-10-12 13:56:15 -04:00
Patrick Palka
d187dfbd03 libstdc++: Fix up implementation of LWG 3533 [PR101589]
In r12-569 I accidentally applied the LWG 3533 change to
elements_view::iterator::base instead to elements_view::base.

This patch corrects this, and also applies the corresponding LWG 3533
change to lazy_split_view::inner-iter::base now that we implement P2210.

	PR libstdc++/101589

libstdc++-v3/ChangeLog:

	* include/std/ranges (lazy_split_view::_InnerIter::base): Make
	the const& overload unconstrained and return a const reference
	as per LWG 3533.  Make unconditionally noexcept.
	(elements_view::base): Revert accidental r12-569 change.
	(elements_view::_Iterator::base): Make the const& overload
	unconstrained and return a const reference as per LWG 3533.
	Make unconditionally noexcept.

(cherry picked from commit 4414057186)
2021-10-12 13:55:05 -04:00
Patrick Palka
58873a5658 libstdc++: Add missing std::move to join_view::iterator ctor [PR101483]
PR libstdc++/101483

libstdc++-v3/ChangeLog:

	* include/std/ranges (join_view::_Iterator::_Iterator): Add
	missing std::move.

(cherry picked from commit 0e1bb3c88c)
2021-10-12 13:54:16 -04:00
Patrick Palka
565602a23a libstdc++: Define split_view::_InnerIter::base as per P2210
libstdc++-v3/ChangeLog:

	* include/std/ranges (split_view::_InnerIter::base): Define as
	per P2210.

(cherry picked from commit 85a594f7dc)
2021-10-12 13:52:21 -04:00
Patrick Palka
f6c5489475 libstdc++: Implement LWG 3555 changes to transform/elements_view
libstdc++-v3/ChangeLog:

	* include/std/ranges (transform_view::_Iterator::_S_iter_concept):
	Consider _Base instead of _Vp as per LWG 3555.
	(elements_view::_Iterator::_S_iter_concept): Likewise.

(cherry picked from commit bc046a60cf)
2021-10-12 13:51:51 -04:00
Patrick Palka
01e1cadac2 libstdc++: Implement LWG 3553 changes to split_view
libstdc++-v3/ChangeLog:

	* include/std/ranges (split_view::_OuterIter::value_type::begin):
	Remove the non-const overload, and remove the copyable constraint
	on the const overload as per LWG 3553.

(cherry picked from commit 15736576df)
2021-10-12 13:51:31 -04:00
Patrick Palka
bc6059e257 libstdc++: Implement LWG 3546 changes to common_iterator
libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h
	(__detail::__common_iter_use_postfix_proxy): Add
	move_constructible constraint as per LWG 3546.
	(common_iterator::__postfix_proxy): Adjust initializer of
	_M_keep as per LWG 3546.

(cherry picked from commit 4123650bd0)
2021-10-12 13:50:03 -04:00
Patrick Palka
3c2397242a libstdc++: Implement LWG 3557 change to convertible_to
libstdc++-v3/ChangeLog:

	* include/std/concepts (convertible_to): Just use declval as per
	LWG 3557.

(cherry picked from commit 83faf7eacd)
2021-10-12 13:49:47 -04:00
Patrick Palka
166bf5e7ba libstdc++: Move ranges algos used by <ranges> into ranges_util.h
The <ranges> header defines simplified copies of some ranges algorithms
in order to avoid including the entirety of ranges_algo.h.  A subsequent
patch is going to want to use ranges::search in <ranges> as well, and
that algorithm is more complicated compared to the other copied ones.

So rather than additionally copying ranges::search into <ranges>, this
patch splits out all the ranges algos used by <ranges> (including
ranges::search) from ranges_algo.h to ranges_util.h, and deletes the
simplified copies in <ranges>.  This seems like the best place to
put these algorithms, as ranges_util.h is currently included only from
<ranges> and ranges_algo.h.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__find_fn, find, __find_if_fn)
	(find_if, __find_if_not_fn, find_if_not, _in_in_result)
	(__mismatch_fn, mismatch, __search_fn, search): Move to ...
	* include/bits/ranges_util.h: ... here.
	* include/std/ranges (__detail::find, __detail::find_if)
	(__detail::find_if_not, __detail::mismatch): Remove.
	(filter_view): Use ranges::find_if instead.
	(drop_while_view): Use ranges::find_if_not instead.
	(split_view): Use ranges::find and ranges::mismatch instead.

(cherry picked from commit 2786064d91)
2021-10-12 13:49:25 -04:00
Patrick Palka
0dd0905e2f libstdc++: Implement LWG 3490 change to drop_while_view::begin()
libstdc++-v3/ChangeLog:

	PR libstdc++/100606
	* include/std/ranges (drop_while_view::begin): Assert the
	precondition added by LWG 3490.

(cherry picked from commit 11784fe27d)
2021-10-12 13:49:02 -04:00
Jonathan Wakely
8104d4fff6 libstdc++: Fix test that fails for C++20
Restore the test for 'a < a' that was removed by r12-2537 because
it is ill-formed. We still want to test operator< for tuple, we just
need to not use std::nullptr_t in that tuple type.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/tuple/comparison_operators/overloaded.cc:
	Restore test for operator<.

(cherry picked from commit 727137d6ca)
2021-10-12 16:54:57 +01:00
Jonathan Wakely
e748216c23 libstdc++: Fix move construction of std::tuple with array elements [PR101960]
The r12-3022 commit only fixed the case where an array is the last
element of the tuple. This fixes the other cases too. We can just define
the move constructor as defaulted, which does the right thing. Changing
the move constructor to be trivial would be an ABI break, but since the
last base class still has a non-trivial move constructor, defining the
derived ones as defaulted doesn't change anything.

libstdc++-v3/ChangeLog:

	PR libstdc++/101960
	* include/std/tuple (_Tuple_impl(_Tuple_impl&&)): Define as
	defauled.
	* testsuite/20_util/tuple/cons/101960.cc: Check tuples with
	array elements before the last element.

(cherry picked from commit 7481021364)
2021-10-12 16:53:56 +01:00
Jonathan Wakely
7b4e6d75b1 libstdc++: Fix testcase for newly-implemented C++20 semantics [PR102535]
libstdc++-v3/ChangeLog:

	PR c++/102535
	* testsuite/20_util/is_trivially_constructible/value.cc: Adjust
	expected value for C++20.

(cherry picked from commit 7646847df7)
2021-10-12 11:45:46 +01:00
Jonathan Wakely
38dc85da40 libstdc++: Move test that depends on wchar_t I/O to wchar_t sub-directory
This fixes a FAIL when --disable-wchar_t is used.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_filebuf/close/81256.cc: Moved to...
	* testsuite/27_io/basic_filebuf/close/wchar_t/81256.cc: ...here.

(cherry picked from commit cfeff094e6)
2021-10-12 11:45:46 +01:00
Jonathan Wakely
b8fccd58ee libstdc++: Ensure std::span and std::string_view are trivially copyable (P2251R1)
The recently approved P2251R1 paper requires these types to be trivially
copyable. They always have been in libstdc++, but add tests to check it.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string_view/requirements/trivially_copyable.cc:
	New test.
	* testsuite/23_containers/span/trivially_copyable.cc: New test.

(cherry picked from commit 1f51e9af7b)
2021-10-12 11:45:45 +01:00
Jonathan Wakely
60c20a314d libstdc++: Fix std::numeric_limits::lowest() test for strict modes
This test uses std::is_integral to decide whether we are testing an
integral or floating-point type. But that fails for __int128 because
is_integral<__int128> is false in strict modes. By using
numeric_limits::is_integer instead we get the right answer for all types
that have a numeric_limits specialization.

We can also simplify the test by removing the unnecessary tag
dispatching.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/numeric_limits/lowest.cc: Use
	numeric_limits<T>::is_integer instead of is_integral<T>::value.

(cherry picked from commit 45ba5426c1)
2021-10-12 11:45:45 +01:00
Jonathan Wakely
00967465fe libstdc++: Fix move construction of std::tuple with array elements [PR101960]
An array member cannot be direct-initialized in a ctor-initializer-list,
so use the base class' move constructor, which does the right thing for
both arrays and non-arrays.

This constructor could be defaulted, but that would make it trivial for
some specializations, which would change the argument passing ABI. Do
that for the versioned namespace only.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101960
	* include/std/tuple (_Tuple_impl(_Tuple_impl&&)): Use base
	class' move constructor. Define as defaulted for versioned
	namespace.
	* testsuite/20_util/tuple/cons/101960.cc: New test.

(cherry picked from commit 0187e0d736)
2021-10-12 11:45:45 +01:00
Jonathan Wakely
822bd7f6a2 libstdc++: Fix CTAD for debug sequence containers
This fixes some 23_containers/*/cons/deduction.cc failures seen with
-std=c++17/-D_GLIBCXX_DEBUG, caused by non-immediate errors when
substituting template arguments into an incorrect specialization of the
std::__cxx1998 base class. This happens because the size_type member of
the debug container is _Base_type::size_type, so is non-deducible, and
the deduced types get substituted into _Base_type, triggering the
static_assert that checks the allocator's value_type matches the
container's.

The solution is to make the C(size_type, const T&, const Alloc&)
constructors of the debug sequence containers non-deducible. In order to
make CTAD work again deduction guides that use std::size_t for the first
argument are added.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/debug/deque (deque(size_type, const T&, const A&)):
	Prevent class template argument deduction and replace with a
	deduction guide.
	* include/debug/forward_list (forward_list(size_type, const T&, const A&)):
	Likewise.
	* include/debug/list (list(size_type, const T&, const A&)):
	Likewise.
	* include/debug/vector (vector(size_type, const T&, const A&)):
	Likewise.

(cherry picked from commit 085c2f8f0e)
2021-10-12 11:45:45 +01:00
Jonathan Wakely
a9e07e1651 libstdc++: Install GDB pretty printers for debug library
The additional libraries installed by --enable-libstdcxx-debug are built
without optimization to aid debugging, but the Python pretty printers
are not installed alongside them. This means that you can step through
the unoptimized library code, but at the expense of pretty printing the
library types.

This remedies the situation by installing another copy of the GDB hooks
alongside the debug version of libstdc++.so.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* python/Makefile.am [GLIBCXX_BUILD_DEBUG] (install-data-local):
	Install another copy of the GDB hook.
	* python/Makefile.in: Regenerate.

(cherry picked from commit db853ff78a)
2021-10-12 11:45:45 +01:00
Jonathan Wakely
371e12a7fd libstdc++: Add additional overload of std::lerp [PR101870]
The [cmath.syn] p1 wording about additional overloads sufficient to
handle any arithmetic types also applies to std::lerp. This adds a new
overload of std::lerp that does the required promotions to support
arguments of arbitrary arithmetic types.

A new __promoted_t alias template is added, which the C++17 function
templates std::hypot and std::lerp can use to avoid instantiating the
__promote_3 class template.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101870
	* include/c_global/cmath (hypot): Use __promoted_t.
	(lerp): Add new overload accepting any arithmetic types.
	* include/ext/type_traits.h (__promoted_t): New alias template.
	* testsuite/26_numerics/lerp.cc: Moved to...
	* testsuite/26_numerics/lerp/1.cc: ...here.
	* testsuite/26_numerics/lerp/constexpr.cc: New test.
	* testsuite/26_numerics/lerp/version.cc: New test.

(cherry picked from commit 9017326e19)
2021-10-12 11:45:44 +01:00
Jonathan Wakely
b4f5e4c045 libstdc++: Add pretty printer for std::error_code and std::error_condition
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Define.
	(build_libstdcxx_dictionary): Register printer for
	std::error_code and std::error_condition.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Test it.

(cherry picked from commit 2db38d9fca)
2021-10-12 11:45:44 +01:00
Jonathan Wakely
73b0f810a1 libstdc++: Optimize std::function move constructor [PR101923]
PR 101923 points out that the unconditional swap in the std::function
move constructor makes it slower than copying an empty std::function.
The copy constructor has to check for the empty case before doing
anything, and that makes it very fast for the empty case.

Adding the same check to the move constructor avoids copying the
_Any_data POD when we don't need to. We can also inline the effects of
swap, by copying each member and then zeroing the pointer members.

This makes moving an empty object at least as fast as copying an empty
object.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101923
	* include/bits/std_function.h (function(function&&)): Check for
	non-empty parameter before doing any work.

(cherry picked from commit 0808b0df9c)
2021-10-12 11:45:44 +01:00
Jonathan Wakely
da206878f6 libstdc++: std::system_category should know meaning of zero [PR102425]
Although 0 is not an errno value, it should still be recognized as
corresponding to a value belonging to the generic_category().

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/102425
	* src/c++11/system_error.cc
	(system_error_category::default_error_condition): Add 0 to
	switch.
	* testsuite/19_diagnostics/error_category/102425.cc: New test.

(cherry picked from commit ce01e2e64c)
2021-10-12 11:45:44 +01:00
Thomas Rodgers
90a4981e09 libstdc++: Fix UB in atomic_ref/wait_notify.cc [PR101761]
Remove UB in atomic_ref/wait_notify test.

Signed-off-by: Thomas Rodgers <trodgers@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101761
	* testsuite/29_atomics/atomic_ref/wait_notify.cc (test): Use
	va and vb as arguments to wait/notify, remove unused bb local.

(cherry picked from commit f9f1a6efaa)
2021-10-12 11:45:44 +01:00
Jonathan Wakely
ae9e270347 libstdc++: Remove non-deducible parameter for std::advance overload
This was just a copy and paste error.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/fs_path.h (advance): Remove non-deducible
	template parameter.

(cherry picked from commit 21c760510d)
2021-10-12 11:45:44 +01:00
Jonathan Wakely
7df66a0c95 libstdc++: Fix inefficiency in filesystem::absolute [PR99876]
When the path is already absolute, the call to current_path() is
wasteful, because operator/ will ignore the left operand anyway.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/99876
	* src/c++17/fs_ops.cc (fs::absolute): Call non-throwing form,
	to avoid unnecessary current_path() call.

(cherry picked from commit 07b990ee23)
2021-10-12 11:45:43 +01:00
Jonathan Wakely
aeee9251c6 libstdc++: Add missing return for atomic timed wait [PR102074]
This adds a missing return statement to the non-futex wait-until
operation.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/102074
	* include/bits/atomic_timed_wait.h (__timed_waiter_pool)
	[!_GLIBCXX_HAVE_PLATFORM_TIMED_WAIT]: Add missing return.

(cherry picked from commit 763eb1f192)
2021-10-12 11:45:43 +01:00
Jonathan Wakely
9c2eea2841 libstdc++: Fix last std::tuple constructor missing 'constexpr' [PR102270]
Also rename the test so it actually runs.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/102270
	* include/std/tuple (_Tuple_impl): Add constexpr to constructor
	missed in previous patch.
	* testsuite/20_util/tuple/cons/102270.C: Moved to...
	* testsuite/20_util/tuple/cons/102270.cc: ...here.
	* testsuite/util/testsuite_allocator.h (SimpleAllocator): Add
	constexpr to constructor so it can be used for C++20 tests.

(cherry picked from commit 1fa2c5a695)
2021-10-12 11:45:43 +01:00
Jonathan Wakely
63d91069ba libstdc++: Add missing 'constexpr' to std::tuple [PR102270]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/102270
	* include/std/tuple (_Head_base, _Tuple_impl): Add
	_GLIBCXX20_CONSTEXPR to allocator-extended constructors.
	(tuple<>::swap(tuple&)): Add _GLIBCXX20_CONSTEXPR.
	* testsuite/20_util/tuple/cons/102270.C: New test.

(cherry picked from commit 734b2c2eed)
2021-10-12 11:45:43 +01:00
Jonathan Wakely
06e88b7d61 libstdc++: Rename tests with incorrect extension
The libstdc++ testsuite only runs .cc files, so these two old tests have
never been run.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/valarray/dr630-3.C: Moved to...
	* testsuite/26_numerics/valarray/dr630-3.cc: ...here.
	* testsuite/27_io/basic_iostream/cons/16251.C: Moved to...
	* testsuite/27_io/basic_iostream/cons/16251.cc: ...here.

(cherry picked from commit 749c31b345)
2021-10-12 11:45:43 +01:00
Jonathan Wakely
95d404d85c libstdc++: Add missing constraint to std::span deduction guide [PR102280]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/102280
	* include/std/span (span(Range&&)): Add constraint to deduction
	guide.

(cherry picked from commit e67917f5df)
2021-10-12 11:45:42 +01:00
Jonathan Wakely
cfddef4e6b libstdc++: Add missing header to test
We need to include <iterator> (or one of the containers) to get a
definition for std::begin.

libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/is_permutation/2.cc: Include <iterator>.

(cherry picked from commit 94311bf347)
2021-10-12 11:45:42 +01:00
Jonathan Wakely
eb7566fef5 libstdc++: Add test for std::cmp_greater
This was omitted from the commit that added these comparisons.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/integer_comparisons/greater.cc: New test.

(cherry picked from commit 824e085573)
2021-10-12 11:45:42 +01:00