Commit graph

14203 commits

Author SHA1 Message Date
Jonathan Wakely
481281ccf4 libstdc++: Fix typos in doxygen comments
libstdc++-v3/ChangeLog:

	* include/bits/mofunc_impl.h: Fix typo in doxygen comment.
	* include/std/format: Likewise.
2023-04-27 11:28:40 +01:00
Jonathan Wakely
efa1276480 libstdc++: Remove obsolete options from Doxygen config
libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (FORMULA_TRANSPARENT, DOT_FONTNAME)
	(DOT_FONTSIZE, DOT_TRANSPARENT): Remove obsolete options.
2023-04-27 11:28:39 +01:00
Jonathan Wakely
afa69618d1 libstdc++: Reduce Doxygen output for PDF
Including the header source code in the doxygen-generated PDF file makes
it too large, and causes pdflatex to run out of memory. If we only set
SOURCE_BROWSER=YES for the HTML docs then we won't include the sources
in the PDF file.

There are several macros defined for std::valarray that are only used to
generate repetitive code and then #undef'd. Those aren't useful in the
doxygen docs, especially the ones that reuse the same name in different
files. Omitting them avoids warnings about duplicate labels in the
refman.tex file.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (SOURCE_BROWSER): Only set to YES for
	HTML docs.
	* include/bits/gslice_array.h (_DEFINE_VALARRAY_OPERATOR): Omit
	from doxygen docs.
	* include/bits/indirect_array.h (_DEFINE_VALARRAY_OPERATOR):
	Likewise.
	* include/bits/mask_array.h (_DEFINE_VALARRAY_OPERATOR):
	Likewise.
	* include/bits/slice_array.h (_DEFINE_VALARRAY_OPERATOR):
	Likewise.
	* include/std/valarray (_DEFINE_VALARRAY_UNARY_OPERATOR)
	(_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT)
	(_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT)
	(_DEFINE_BINARY_OPERATOR): Likewise.
2023-04-27 11:28:39 +01:00
Jonathan Wakely
afcf2b09b8 libstdc++: Improve doxygen docs for <memory_resource>
libstdc++-v3/ChangeLog:

	* include/bits/memory_resource.h: Improve doxygen comments.
	* include/std/memory_resource: Likewise.
2023-04-27 11:28:39 +01:00
Jonathan Wakely
865869dc69 libstdc++: Add @headerfile and @since to doxygen comments [PR40380]
libstdc++-v3/ChangeLog:

	PR libstdc++/40380
	* include/bits/basic_string.h: Improve doxygen comments.
	* include/bits/cow_string.h: Likewise.
	* include/bits/forward_list.h: Likewise.
	* include/bits/fs_dir.h: Likewise.
	* include/bits/fs_path.h: Likewise.
	* include/bits/quoted_string.h: Likewise.
	* include/bits/stl_bvector.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.
	* include/bits/unordered_map.h: Likewise.
	* include/bits/unordered_set.h: Likewise.
	* include/std/filesystem: Likewise.
	* include/std/iomanip: Likewise.
2023-04-27 11:28:39 +01:00
Jonathan Wakely
f9412cedd6 libstdc++: Make std::random_device throw std::system_error [PR105081]
This changes std::random_device constructors to throw std::system_error
(with EINVAL as the error code) when the constructor argument is
invalid. We can also throw std::system_error when read(2) fails so that
the exception includes the additional information provided by errno.

As noted in the PR, this is consistent with libc++, and doesn't break
any existing code which catches std::runtime_error, because those
handlers will still catch std::system_error.

libstdc++-v3/ChangeLog:

	PR libstdc++/105081
	* src/c++11/random.cc (__throw_syserr): New function.
	(random_device::_M_init, random_device::_M_init_pretr1): Use new
	function for bad tokens.
	(random_device::_M_getval): Use new function for read errors.
	* testsuite/util/testsuite_random.h (random_device_available):
	Change catch handler to use std::system_error.
2023-04-27 11:28:39 +01:00
GCC Administrator
aeaf942699 Daily bump. 2023-04-25 00:17:46 +00:00
Patrick Palka
83470a5cd4 libstdc++: Fix __max_diff_type::operator>>= for negative values
This patch fixes sign bit propagation when right-shifting a negative
__max_diff_type value by more than one, a bug that our existing test
coverage didn't expose until r14-159-g03cebd304955a6 fixed the front
end's 'signed typedef-name' handling that the test relies on (which is
a non-standard extension to the language grammar).

libstdc++-v3/ChangeLog:

	* include/bits/max_size_type.h (__max_diff_type::operator>>=):
	Fix propagation of sign bit.
	* testsuite/std/ranges/iota/max_size_type.cc: Avoid using the
	non-standard 'signed typedef-name'.  Add some compile-time tests
	for right-shifting a negative __max_diff_type value by more than
	one.
2023-04-24 13:39:54 -04:00
GCC Administrator
cf0d9dbc09 Daily bump. 2023-04-20 00:17:12 +00:00
Patrick Palka
58b7dbf865 c++: Define built-in for std::tuple_element [PR100157]
This adds a new built-in to replace the recursive class template
instantiations done by traits such as std::tuple_element and
std::variant_alternative.  The purpose is to select the Nth type from a
list of types, e.g. __type_pack_element<1, char, int, float> is int.
We implement it as a special kind of TRAIT_TYPE.

For a pathological example tuple_element_t<1000, tuple<2000 types...>>
the compilation time is reduced by more than 90% and the memory used by
the compiler is reduced by 97%.  In realistic examples the gains will be
much smaller, but still relevant.

Unlike the other built-in traits, __type_pack_element uses template-id
syntax instead of call syntax and is SFINAE-enabled, matching Clang's
implementation.  And like the other built-in traits, it's not mangleable
so we can't use it directly in function signatures.

N.B. Clang seems to implement __type_pack_element as a first-class
template that can e.g. be used as a template-template argument.  For
simplicity we implement it in a more ad-hoc way.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

	PR c++/100157

gcc/cp/ChangeLog:

	* cp-trait.def (TYPE_PACK_ELEMENT): Define.
	* cp-tree.h (finish_trait_type): Add complain parameter.
	* cxx-pretty-print.cc (pp_cxx_trait): Handle
	CPTK_TYPE_PACK_ELEMENT.
	* parser.cc (cp_parser_constant_expression): Document default
	arguments.
	(cp_parser_trait): Handle CPTK_TYPE_PACK_ELEMENT.  Pass
	tf_warning_or_error to finish_trait_type.
	* pt.cc (tsubst) <case TRAIT_TYPE>: Handle non-type first
	argument.  Pass complain to finish_trait_type.
	* semantics.cc (finish_type_pack_element): Define.
	(finish_trait_type): Add complain parameter.  Handle
	CPTK_TYPE_PACK_ELEMENT.
	* tree.cc (strip_typedefs): Handle non-type first argument.
	Pass tf_warning_or_error to finish_trait_type.
	* typeck.cc (structural_comptypes) <case TRAIT_TYPE>: Use
	cp_tree_equal instead of same_type_p for the first argument.

libstdc++-v3/ChangeLog:

	* include/bits/utility.h (_Nth_type): Conditionally define in
	terms of __type_pack_element if available.
	* testsuite/20_util/tuple/element_access/get_neg.cc: Prune
	additional errors from the new built-in.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/type_pack_element1.C: New test.
	* g++.dg/ext/type_pack_element2.C: New test.
	* g++.dg/ext/type_pack_element3.C: New test.
2023-04-19 15:36:34 -04:00
Jonathan Wakely
fac24d43e6 Revert "libstdc++: Export global iostreams with GLIBCXX_3.4.31 symver [PR108969]"
This reverts commit b7c54e3f48.

libstdc++-v3/ChangeLog:

	* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt:
	* config/abi/post/i486-linux-gnu/baseline_symbols.txt:
	* config/abi/post/m68k-linux-gnu/baseline_symbols.txt:
	* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt:
	* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt:
	* config/abi/post/s390x-linux-gnu/baseline_symbols.txt:
	* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt:
	* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt:
	* config/abi/pre/gnu.ver:
	* src/Makefile.am:
	* src/Makefile.in:
	* src/c++98/Makefile.am:
	* src/c++98/Makefile.in:
	* src/c++98/globals_io.cc (defined):
	(_GLIBCXX_IO_GLOBAL):
2023-04-19 13:18:12 +01:00
Jonathan Wakely
a6e4b81b12 Revert "libstdc++: Fix preprocessor condition in linker script [PR108969]"
This reverts commit 6067ae4557.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver:
2023-04-19 13:18:12 +01:00
GCC Administrator
d5cd3eada4 Daily bump. 2023-04-19 00:17:36 +00:00
Jonathan Wakely
b153f4e4ca libstdc++: Adjust uses of null pointer constants in docs
libstdc++-v3/ChangeLog:

	* doc/xml/manual/extensions.xml: Fix example to declare and
	qualify std::free, and use NULL instead of 0.
	* doc/html/manual/ext_demangling.html: Regenerate.
	* libsupc++/cxxabi.h: Adjust doxygen comments.
2023-04-19 00:13:02 +01:00
Jonathan Wakely
6067ae4557 libstdc++: Fix preprocessor condition in linker script [PR108969]
The linker script is preprocessed with $(top_builddir)/config.h not the
include/$target/bits/c++config.h version, which means that configure
macros do not have the _GLIBCXX_ prefix yet.

The _GLIBCXX_SYMVER_GNU and _GLIBCXX_SHARED checks are redundant,
because the gnu.ver file is only used for _GLIBCXX_SYMVER_GNU and the
linker script is only used for the shared library. Remove those.

libstdc++-v3/ChangeLog:

	PR libstdc++/108969
	* config/abi/pre/gnu.ver: Fix preprocessor condition.
2023-04-18 17:28:29 +01:00
Jonathan Wakely
b7c54e3f48 libstdc++: Export global iostreams with GLIBCXX_3.4.31 symver [PR108969]
Since GCC 13 the global iostream objects are only initialized once in
libstdc++, and not by a std::ios::Init object in every translation unit
that includes <iostream>. To avoid using uninitialized streams defined
in an older libstdc++.so, translation units using the global iostreams
should depend on the GLIBCXX_3.4.31 symver.

Define std::cin as std::__io::cin and then export it as
std::cin@@GLIBCXX_3.4.31 so that references to std::cin bind to the new
symver. Also export it as @GLIBCXX_3.4 for backwards compatibility

libstdc++-v3/ChangeLog:

	PR libstdc++/108969
	* src/Makefile.am: Move globals_io.cc to here.
	* src/Makefile.in: Regenerate.
	* src/c++98/Makefile.am: Remove globals_io.cc from here.
	* src/c++98/Makefile.in: Regenerate.
	* src/c++98/globals_io.cc [_GLIBCXX_SYMVER_GNU] (cin): Adjust
	symbol name and then export with GLIBCXX_3.4.31 symver.
	(cout, cerr, clog, wcin, wcout, wcerr, wclog): Likewise.
	* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/i486-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/m68k-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/s390x-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/pre/gnu.ver: Add iostream objects to new symver.
2023-04-18 16:42:25 +01:00
Patrick Palka
cb5c71d16d libstdc++: Implement range_adaptor_closure from P2387R3 [PR108827]
PR libstdc++/108827

libstdc++-v3/ChangeLog:

	* include/bits/ranges_cmp.h (__cpp_lib_ranges): Bump value
	for C++23.
	* include/std/ranges (range_adaptor_closure): Define for C++23.
	* include/std/version (__cpp_lib_ranges): Bump value for
	C++23.
	* testsuite/std/ranges/version_c++23.cc: Bump expected value
	of __cpp_lib_ranges.
	* testsuite/std/ranges/range_adaptor_closure.cc: New test.
2023-04-18 07:21:13 -04:00
Patrick Palka
95525c5b8c libstdc++: Adding missing feature-test macros for C++23 ranges algos
This patch also renames __cpp_lib_fold to __cpp_lib_ranges_fold
as per the current draft standard.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__cpp_lib_ranges_contains):
	Define for C++23.
	(__cpp_lib_ranges_iota): Likewise.
	(__cpp_lib_ranges_find_last): Likewise.
	(__cpp_lib_fold): Rename to ...
	(__cpp_lib_ranges_fold): ... this.
	* include/std/version: As above.
	* testsuite/25_algorithms/fold_left/1.cc: Adjust after
	renaming __cpp_lib_fold.
	* testsuite/std/ranges/version_c++23.cc: Verify values
	of the above feature-test macros.
2023-04-18 07:21:09 -04:00
Patrick Palka
4ec4ceafcc libstdc++: Fix typo in views::as_const's operator() [PR109525]
PR libstdc++/109525

libstdc++-v3/ChangeLog:

	* include/std/ranges (views::_AsConst::operator()): Add
	missing const to constant_range test.
	* testsuite/std/ranges/adaptors/as_const/1.cc (test02):
	Improve formatting.  Adjust expected type of v2.
	(test03): New test.
2023-04-18 07:21:07 -04:00
GCC Administrator
1aee19f9b5 Daily bump. 2023-04-15 00:16:36 +00:00
Patrick Palka
0d94c6df18 libstdc++: Implement P2278R4 "cbegin should always return a constant iterator"
This also implements the approved follow-up LWG issues 3765, 3766, 3769,
3770, 3811, 3850, 3853, 3862 and 3872.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (const_iterator_t): Define for C++23.
	(const_sentinel_t): Likewise.
	(range_const_reference_t): Likewise.
	(constant_range): Likewise.
	(__cust_access::__possibly_const_range): Likewise, replacing ...
	(__cust_access::__as_const): ... this.
	(__cust_access::_CBegin::operator()): Redefine for C++23 as per P2278R4.
	(__cust_access::_CEnd::operator()): Likewise.
	(__cust_access::_CRBegin::operator()): Likewise.
	(__cust_access::_CREnd::operator()): Likewise.
	(__cust_access::_CData::operator()): Likewise.
	* include/bits/ranges_util.h (ranges::__detail::__different_from):
	Make it an alias of std::__detail::__different_from.
	(view_interface::cbegin): Define for C++23.
	(view_interface::cend): Likewise.
	* include/bits/stl_iterator.h (__detail::__different_from): Define.
	(iter_const_reference_t): Define for C++23.
	(__detail::__constant_iterator): Likewise.
	(__detail::__is_const_iterator): Likewise.
	(__detail::__not_a_const_iterator): Likewise.
	(__detail::__iter_const_rvalue_reference_t): Likewise.
	(__detail::__basic_const_iter_cat):: Likewise.
	(const_iterator): Likewise.
	(__detail::__const_sentinel): Likewise.
	(const_sentinel): Likewise.
	(basic_const_iterator): Likewise.
	(common_type<basic_const_iterator<_Tp>, _Up>): Likewise.
	(common_type<_Up, basic_const_iterator<_Tp>>): Likewise.
	(common_type<basic_const_iterator<_Tp>, basic_const_iterator<Up>>):
	Likewise.
	(make_const_iterator): Define for C++23.
	(make_const_sentinel): Likewise.
	* include/std/ranges (__cpp_lib_ranges_as_const): Likewise.
	(as_const_view): Likewise.
	(enable_borrowed_range<as_const_view>): Likewise.
	(views::__detail::__is_ref_view): Likewise.
	(views::__detail::__can_is_const_view): Likewise.
	(views::_AsConst, views::as_const): Likewise.
	* include/std/span (span::const_iterator): Likewise.
	(span::const_reverse_iterator): Likewise.
	(span::cbegin): Likewise.
	(span::cend): Likewise.
	(span::crbegin): Likewise.
	(span::crend): Likewise.
	* include/std/version (__cpp_lib_ranges_as_const): Likewise.
	* testsuite/std/ranges/adaptors/join.cc (test06): Adjust to
	behave independently of C++20 vs C++23.
	* testsuite/std/ranges/version_c++23.cc: Verify value of
	__cpp_lib_ranges_as_const macro.
	* testsuite/24_iterators/const_iterator/1.cc: New test.
	* testsuite/std/ranges/adaptors/as_const/1.cc: New test.
2023-04-14 10:32:12 -04:00
Patrick Palka
2ab0d83e88 libstdc++: Move down definitions of ranges::cbegin/cend/cetc
This moves down the definitions of the range const-access CPOs to after
the definition of input_range in preparation for implementing P2278R4
which redefines these CPOs in a way that indirectly uses input_range.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (__cust_access::__as_const)
	(__cust_access::_CBegin, __cust::cbegin)
	(__cust_access::_CEnd, __cust::cend)
	(__cust_access::_CRBegin, __cust::crbegin)
	(__cust_access::_CREnd, __cust::crend)
	(__cust_access::_CData, __cust::cdata): Move down definitions to
	shortly after the definition of input_range.
2023-04-14 10:31:54 -04:00
Patrick Palka
7639bf34fa libstdc++: Implement ranges::fold_* from P2322R6
libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h: Include <optional> for C++23.
	(__cpp_lib_fold): Define for C++23.
	(in_value_result): Likewise.
	(__detail::__flipped): Likewise.
	(__detail::__indirectly_binary_left_foldable_impl): Likewise.
	(__detail::__indirectly_binary_left_foldable): Likewise.
	(___detail:__indirectly_binary_right_foldable): Likewise.
	(fold_left_with_iter_result): Likewise.
	(__fold_left_with_iter_fn, fold_left_with_iter): Likewise.
	(__fold_left_fn, fold_left): Likewise.
	(__fold_left_first_with_iter_fn, fold_left_first_with_iter):
	Likewise.
	(__fold_left_first_fn, fold_left_first): Likewise.
	(__fold_right_fn, fold_right): Likewise.
	(__fold_right_last_fn, fold_right_last): Likewise.
	* include/std/version (__cpp_lib_fold): Likewise.
	* testsuite/25_algorithms/fold_left/1.cc: New test.
	* testsuite/25_algorithms/fold_right/1.cc: New test.
2023-04-14 10:31:44 -04:00
Jonathan Wakely
6a9547f3ca libstdc++: Improve diagnostics for invalid std::format calls
Add a static_assert and a comment so that calling std::format for
unformattable argument types will now show:

/home/jwakely/gcc/13/include/c++/13.0.1/format:3563:22: error: static assertion failed: std::formatter must be specialized for each format arg
 3563 |       static_assert((is_default_constructible_v<formatter<_Args, _CharT>> && ...),
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and:

  140 |       formatter() = delete; // No std::formatter specialization for this type.

libstdc++-v3/ChangeLog:

	* include/std/format (formatter): Add comment to deleted default
	constructor of primary template.
	(_Checking_scanner): Add static_assert.
2023-04-14 11:58:39 +01:00
GCC Administrator
66c7257b67 Daily bump. 2023-04-13 00:16:48 +00:00
Jonathan Wakely
adda0e2887 libstdc++: Document libstdc++exp.a library for -fcontracts
libstdc++-v3/ChangeLog:

	* doc/xml/manual/using.xml: Document libstdc++exp.a library.
	* doc/html/*: Regenerate.
2023-04-12 23:26:35 +01:00
Jonathan Wakely
25264f6b3a libstdc++: Fix some AIX test failures
AIX <sys/thread.h> defines struct tstate with non-reserved names, so
adjust the 17_intro/names.cc test. It also defines struct user, which
conflicts with namespace user in some tests.

Replacing the global operator new doesn't work on AIX the same way as it
does for ELF, so skip some tests that depend on replacing it.

Add missing DG directives to synchronized_value test so it doesn't run
for the single-threaded AIX multilib.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc [_AIX]: Do not define policy.
	* testsuite/19_diagnostics/error_code/cons/lwg3629.cc: Rename
	namespace to avoid clashing with libc struct.
	* testsuite/19_diagnostics/error_condition/cons/lwg3629.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/96088.cc: Skip on AIX.
	* testsuite/23_containers/unordered_multimap/96088.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/96088.cc: Likewise.
	* testsuite/23_containers/unordered_set/96088.cc: Likewise.
	* testsuite/experimental/synchronized_value.cc: Require gthreads
	and add missing option for pthreads targets.
2023-04-12 23:25:17 +01:00
Patrick Palka
0f3b4d38d4 libstdc++: Implement ranges::enumerate_view from P2164R9
libstdc++-v3/ChangeLog:

	* include/std/ranges (__cpp_lib_ranges_enumerate): Define
	for C++23.
	(__detail::__range_with_movable_reference): Likewise.
	(enumerate_view): Likewise.
	(enumerate_view::_Iterator): Likewise.
	(enumerate_view::_Sentinel): Likewise.
	(views::__detail::__can_enumerate_view): Likewise.
	(views::_Enumerate, views::enumerate): Likewise.
	* include/std/version (__cpp_lib_ranges_enumerate): Likewise.
	* testsuite/std/ranges/version_c++23.cc: Verify value of
	__cpp_lib_ranges_enumerate.
	* testsuite/std/ranges/adaptors/enumerate/1.cc: New test.
2023-04-12 13:24:37 -04:00
Patrick Palka
aa65771427 libstdc++: Implement LWG 3904 change to lazy_split_view's iterator
libstdc++-v3/ChangeLog:

	* include/std/ranges (lazy_split_view::_OuterIter::_OuterIter):
	Propagate _M_trailing_empty in the const-converting constructor
	as per LWG 3904.
	* testsuite/std/ranges/adaptors/adjacent/1.cc (test04): Correct
	assertion.
	* testsuite/std/ranges/adaptors/lazy_split.cc (test12): New test.
2023-04-12 13:04:36 -04:00
Patrick Palka
13669111e7 libstdc++: Ensure headers used by fast_float are included
This makes floating_from_chars.cc explicitly include all headers
that are used by the original fast_float amalgamation according to
r12-6647-gf5c8b82512f9d3, except:

  1. <cctype> since fast_float doesn't seem to use anything from it
  2. <cinttypes> since fast_float doesn't seem to use anything directly
     from it (this header also pulls in <cstdint>)
  3. <system_error> since std::errc is naturally already available
     from <charconv>

This avoids potential fast_float build failures on platforms for which
some required headers (in particular <cstdint>) end up not getting
transitively included from elsewhere.

libstdc++-v3/ChangeLog:

	* src/c++17/floating_from_chars.cc: Include <algorithm>,
	<iterator>, <limits> and <cstdint>.
2023-04-12 12:40:41 -04:00
Patrick Palka
ae8f903632 libstdc++: Fix chunk_by_view when value_type& and reference differ [PR108291]
PR libstdc++/108291

libstdc++-v3/ChangeLog:

	* include/std/ranges (chunk_by_view::_M_find_next): Generalize
	parameter types of the lambda wrapper passed to adjacent_find.
	(chunk_by_view::_M_find_prev): Likewise.
	* testsuite/std/ranges/adaptors/chunk_by/1.cc (test04, test05):
	New tests.
2023-04-12 12:10:23 -04:00
Jonathan Wakely
9f10b4957c libstdc++: Initialize all members of basic_endpoint union [PR109482]
On Solaris the in_addr struct contains a union and value-initializing it
does not make the s_addr member active. This means we can't access that
member later during constant evaluation.

Make the constructors explicitly set every member that we might want to
read later in constexpr member functions. This means even the default
constructor can only be constexpr for C++20, because we can't change the
active member of a union in older standards.

libstdc++-v3/ChangeLog:

	PR libstdc++/109482
	* include/experimental/internet (basic_endpoint::basic_endpoint()):
	Ensure that the required union members are active. Only define
	as constexpr for C++20 and later.
	(basic_endpoint::basic_endpoint(const protocol_type&, port_type)):
	Likewise.
	* testsuite/experimental/net/internet/endpoint/cons.cc: Only
	check constexpr default constructor for C++20 and later.
	* testsuite/experimental/net/internet/endpoint/extensible.cc:
	Likewise.
2023-04-12 13:15:12 +01:00
Jonathan Wakely
88ed90187f libstdc++: Update tzdata to 2023c
Import the new 2023c tzdata.zi file.

libstdc++-v3/ChangeLog:

	* src/c++20/tzdata.zi: Import new file from 2023c release.
2023-04-12 13:15:12 +01:00
GCC Administrator
5229788da7 Daily bump. 2023-04-06 00:16:43 +00:00
Arsen Arsenović
3bfd0420e4
libstdc++: Fix some freestanding test failures
At some point, <charconv> was added to the non-hosted bit of the C++17
block, which induced failures in many tests.

In addition, some tests also lacked a dg-require-effective-target hosted
tag.

libstdc++-v3/ChangeLog:

	* include/precompiled/stdc++.h (C++17): Don't double-include
	<charconv>, once with wrong conditions.
	* testsuite/18_support/96817.cc: Require hosted.
	* testsuite/18_support/bad_exception/59392.cc: Ditto.
	* testsuite/20_util/scoped_allocator/108952.cc: Ditto.
	* testsuite/20_util/uses_allocator/lwg3527.cc: Ditto.
	* testsuite/29_atomics/atomic/operators/pointer_partial_void.cc:
	Ditto.
2023-04-05 18:45:15 +02:00
Arsen Arsenović
bff26ac162
libstdc++: Downgrade DEBUG to ASSERTIONS when !HOSTED
Supporting the debug mode in freestanding is a non-trivial job, so
instead, as a best-effort, enable assertions, which are light and easy.

libstdc++-v3/ChangeLog:

	* include/bits/c++config: When __STDC_HOSTED__ is zero,
	disable _GLIBCXX_DEBUG and, if it was set, enable
	_GLIBCXX_ASSERTIONS.
	* testsuite/lib/libstdc++.exp (check_v3_target_debug_mode):
	Include <bits/c++config.h> when determining whether debug is
	set, in order to inherit the logic from above
2023-04-05 18:45:14 +02:00
Arsen Arsenović
6f0d67b912
libstdc++: Add a test for <version> FTM redefinitions
This test detects redefinitions by compiling stdc++.h and <version>, by
disabling the system_header pragma on the latter, to allow warnings in
it.  Thanks Patrick Palka for the suggestion.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/versionconflict.cc: New test.
	* include/std/version: Allow disabling the system_header pragma
	via _GLIBCXX_TESTING_SYSHDR.
2023-04-05 18:45:14 +02:00
Arsen Arsenović
9d63ce7c4c
libstdc++: Harmonize <version> and other headers
Due to recent, large changes in libstdc++, the feature test macros
declared in <version> got out of sync with the other headers that
possibly declare them.

libstdc++-v3/ChangeLog:

	* include/bits/unique_ptr.h (__cpp_lib_constexpr_memory):
	Synchronize the definition block with...
	* include/bits/ptr_traits.h (__cpp_lib_constexpr_memory):
	... this one here.  Also define the 202202L value, rather than
	leaving it up to purely unique_ptr.h, so that the value is
	synchronized across all headers.
	(__gnu_debug::_Safe_iterator_base): Move into new conditional
	block.
	* include/std/memory (__cpp_lib_atomic_value_initialization):
	Define on freestanding under the same conditions as in
	atomic_base.h.
	* include/std/version (__cpp_lib_robust_nonmodifying_seq_ops):
	Also define on freestanding.
	(__cpp_lib_to_chars): Ditto.
	(__cpp_lib_gcd): Ditto.
	(__cpp_lib_gcd_lcm): Ditto.
	(__cpp_lib_raw_memory_algorithms): Ditto.
	(__cpp_lib_array_constexpr): Ditto.
	(__cpp_lib_nonmember_container_access): Ditto.
	(__cpp_lib_clamp): Ditto.
	(__cpp_lib_constexpr_char_traits): Ditto.
	(__cpp_lib_constexpr_string): Ditto.
	(__cpp_lib_sample): Ditto.
	(__cpp_lib_lcm): Ditto.
	(__cpp_lib_constexpr_iterator): Ditto.
	(__cpp_lib_constexpr_char_traits): Ditto.
	(__cpp_lib_interpolate): Ditto.
	(__cpp_lib_constexpr_utility): Ditto.
	(__cpp_lib_shift): Ditto.
	(__cpp_lib_ranges): Ditto.
	(__cpp_lib_move_iterator_concept): Ditto.
	(__cpp_lib_constexpr_numeric): Ditto.
	(__cpp_lib_constexpr_functional): Ditto.
	(__cpp_lib_constexpr_algorithms): Ditto.
	(__cpp_lib_constexpr_tuple): Ditto.
	(__cpp_lib_constexpr_memory): Ditto.
2023-04-05 18:45:14 +02:00
John David Anglin
85cefbc66e Fix 22_locale/locale/cons/12658_thread-2.cc on hppa.
2023-04-05  John David Anglin  <danglin@gcc.gnu.org>

libstdc++-v3/ChangeLog:

	* testsuite/22_locale/locale/cons/12658_thread-2.cc: Double
	timeout factor on hppa*-*-*.
2023-04-05 15:40:52 +00:00
Jonathan Wakely
44e17b8d89 libstdc++: Define std::sub_match::swap member function (LWG 3204)
This was approved at the C++ meeting in February.

libstdc++-v3/ChangeLog:

	* include/bits/regex.h (sub_match::swap): New function.
	* testsuite/28_regex/sub_match/lwg3204.cc: New test.
2023-04-05 11:37:19 +01:00
GCC Administrator
645b136251 Daily bump. 2023-04-05 00:16:53 +00:00
Jonathan Wakely
688d126b69 libstdc++: Fix outdated docs about demangling exception messages
The string returned by std::bad_exception::what() hasn't been a mangled
name since PR libstdc++/14493 was fixed for GCC 4.2.0, so remove the
docs showing how to demangle it.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/extensions.xml: Remove std::bad_exception from
	example program.
	* doc/html/manual/ext_demangling.html: Regenerate.
2023-04-04 12:15:59 +01:00
GCC Administrator
e11cde0381 Daily bump. 2023-04-01 00:17:38 +00:00
Jonathan Wakely
4969dcd2b7 libstdc++: Teach optimizer that empty COW strings are empty [PR107087]
The compiler doesn't know about the invariant that the _S_empty_rep()
object is immutable and so _M_length and _M_refcount are always zero.
This means that we get warnings about writing possibly-non-zero length
strings into buffers that can't hold them. If we teach the compiler that
the empty rep is always zero length, it knows it can be copied into any
buffer.

For Stage 1 we might want to also consider adding this to capacity():

	if (_S_empty_rep()._M_capacity != 0)
	  __builtin_unreachable();

And this to _Rep::_M_is_leaked() and _Rep::_M_is_shared():

	  if (_S_empty_rep()._M_refcount != 0)
	    __builtin_unreachable();

libstdc++-v3/ChangeLog:

	PR tree-optimization/107087
	* include/bits/cow_string.h (basic_string::size()): Add
	optimizer hint that _S_empty_rep()._M_length is always zero.
	(basic_string::length()): Call size().
2023-03-31 23:45:13 +01:00
Jonathan Wakely
a35e8042fb libstdc++: Avoid -Wmaybe-uninitialized warning in std::stop_source [PR109339]
We pass a const-reference to *this before it's constructed, and GCC
assumes that all const-references are accessed. Add the access attribute
to say it's not accessed.

libstdc++-v3/ChangeLog:

	PR libstdc++/109339
	* include/std/stop_token (_Stop_state_ptr(const stop_source&)):
	Add attribute access with access-mode 'none'.
	* testsuite/30_threads/stop_token/stop_source/109339.cc: New test.
2023-03-31 14:20:52 +01:00
Jonathan Wakely
10e573e86c libstdc++: Revert addition of boolean flag to net::ip::basic_endpoint
As pointed out in P2641R1, we can use GCC's __builtin_constant_p to
emulate the proposed std::is_active_member. This allows us to detect
which of the union members is active during constant evaluation, so we
don't need the extra bool data member. We still can't support constexpr
until C++20 though, as we need to change the active member during
constant evaluation.

libstdc++-v3/ChangeLog:

	* include/experimental/internet (ip::basic_endpoint::_M_if_v6):
	Revert change from member function to data member. Fix for
	constant evaluation by detecting which union member is active.
	(ip::basic_endpoint::resize): Revert changes to update _M_is_v6
	flag.
2023-03-31 14:20:51 +01:00
GCC Administrator
0090888656 Daily bump. 2023-03-30 00:17:02 +00:00
Jonathan Wakely
ee122a2eea libstdc++: Fix filename of new test [PR109242]
libstdc++-v3/ChangeLog:

	PR libstdc++/109242
	* testsuite/20_util/optional/monadic/pr109340.cc: Moved to...
	* testsuite/20_util/optional/monadic/pr109242.cc: ...here.
2023-03-30 00:42:11 +01:00
Jonathan Wakely
e0d77144aa libstdc++: Fix constexpr functions in <experimental/internet>
Change ip::basic_endpoint to work in constant expressions, but only for
C++20 and later (due to the use of a union, which cannot change active
member in constexpr evaluation until C++20).

During constant evaluation we cannot inspect the common initial sequence
of basic_endpoint's union members to check whether sin_family == AF_INET
or AF_INET6.  This means we need to store an additional boolean member
that remembers whether we have a v4 or v6 address. The address type can
change behind our backs if a user copies an address to the data()
pointer and then calls resize(n), so we need to inspect the sa_family_t
member in the union after a resize and update the boolean. POSIX only
guarantees that the sa_family_t member of each protocol-specific address
structure is at the same offset and of the same type, not that there is
a common initial sequence. The check in resize is done using memcmp, so
that we avoid accessing an inactive member of the union if the
sockaddr_in and sockaddr_in6 structures do not have a common initial
sequence that includes the sa_family_t member.

libstdc++-v3/ChangeLog:

	* include/experimental/internet (ip::make_address): Implement
	missing overload.
	(ip::address_v4::broadcast()): Avoid undefined shift.
	(ip::basic_endpoint): Fix member functions for constexpr.
	(ip::basic_endpoint::_M_is_v6): Replace member function with
	data member, adjust member functions using it.
	(ip::basic_endpoint::resize): Update _M_is_v6 based on sockaddr
	content.
	* testsuite/experimental/net/internet/address/v4/cons.cc: Fix
	constexpr checks to work in C++14.
	* testsuite/experimental/net/internet/address/v4/creation.cc:
	Likewise.
	* testsuite/experimental/net/internet/endpoint/cons.cc:
	Likewise.
	* testsuite/experimental/net/internet/network/v4/cons.cc:
	Likewise.
	* testsuite/experimental/net/internet/network/v4/members.cc:
	Likewise.
	* testsuite/experimental/net/internet/endpoint/extensible.cc: New test.
2023-03-30 00:36:08 +01:00
Jonathan Wakely
ce39714a1c libstdc++: Apply small fix from LWG 3843 to std::expected
LWG 3843 adds some type requirements to std::expected::value to ensure
that it can correctly copy the error value if it needs to throw an
exception. We don't need to do anything to enforce that, because it will
already be ill-formed if the type can't be copied. The issue also makes
a small drive-by fix to ensure that a const E& is copied from the
non-const value()& overload, which this change implements.

libstdc++-v3/ChangeLog:

	* include/std/expected (expected::value() &): Use const lvalue
	for unex member passed to bad_expected_access constructor, as
	per LWG 3843.
2023-03-30 00:06:25 +01:00