Commit Graph

516 Commits

Author SHA1 Message Date
Marek Polacek
3d17243e1f Initial version of P2996, Reflection for C++26
Based on r12 of the draft.
2026-01-14 10:56:13 -05:00
Jakub Jelinek
62c126db6b libstdc++: Implement C++26 P3378R2 - constexpr exception types
The following patch attempts to implement the C++26 P3378R2 - constexpr
exception types paper.

This is quite complicated, because most of these classes which should
be constexpr-ized use solely or mostly out of line definitions in
libstdc++, both for historical, code size and dual ABI reasons, so that
one can throw these as exceptions between TUs with old vs. new (or vice
versa) ABIs.
For this reason, logic_error/runtime_error and classes derived from it
have the old ABI std::string object inside of them and the exported
APIs from libstdc++.so.6 ensure the right thing.

Now, because new invoked during constant evaluation needs to be deleted
during the same constant evaluation and can't leak into the constant
expressions, I think we don't have to use COW strings under the hood
(which aren't constexpr I guess because of reference counting/COW) and
we can use something else, the patch uses heap allocated std::string
object (where __cow_constexpr_string class has just a pointer to that).
As I think we still want to hide the ugly details if !consteval in the
library, the patch exports 8 __cow_string class symbols (6 existing which
were previously just not exported and 2 new ones) and if !consteval
calls those through extern "C" _Zmangled_name symbols.  The functions
are always_inline.

And then logic_error etc. have for C++26 (precisely for
__cpp_lib_constexpr_exceptions >= 202502L) constexpr definitions of
cdtors/methods.  This results in slightly larger code (a few insns at most)
at runtime for C++26, e.g. instead of calling say some logic error
cdtor/method with 2 arguments it calls some __cow_string one with 2
arguments but + 8 bytes pointer additions on both.

The patch also removes the __throw_format_error forward declaration
which apparently wasn't needed for anything as all __throw_format_error
users were either in <format> or included <format> before the uses,
reverts the
https://gcc.gnu.org/pipermail/libstdc++/2025-July/062598.html
patch and makes sure __throw_* functions (only those for exception types
which the P3378R2 or P3068R5 papers made constexpr usable and there are
actually constexpr/consteval uses of those) are constexpr for C++26
constexpr exceptions.

The patch does that by splitting the bits/functexcept.h header:
1) bits/functexcept.h stays for the __throw_* functions which are (at
least for now) never constexpr (the <ios>, <system_error>, <future>
and <functional> std::exception derived classes) or are never used
or never used in constexpr/consteval contexts (<exception>, <typeinfo>
std::exception derived classes and std::range_error).
2) bits/new_{throw,except}.h for __throw_bad_alloc/__throw_bad_array_new_length
and std::bad_alloc/std::bad_array_new_length (where <new> includes
<bits/new_except.h> and <bits/new_throw.h> as well for the C++26 constexpr
exceptions case)
3) for the most complicated <stdexcept> stuff, one header
addition to bits/stdexcept.h one header for the __throw_logic_error etc.
forward declarations, one header for the __throw_logic_error etc.
definitions and one header without header guards which will
depending on __glibcxx_exc_in_string include one or the other because
<string> vs. <string_view> vs. <stdexcept> have heavy interdependencies

2025-12-11  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/121114
libstdc++-v3/
	* include/bits/version.def: Implement C++26 P3378R2 - constexpr
	exception types.
	(constexpr_exceptions): Change value from 1 to 202502, remove
	no_stdname and TODO comments.
	* include/bits/version.h: Regenerate.
	* src/c++11/cow-stdexcept.cc (__cow_string(const char*)): New
	ctor.
	(__cow_string::c_str()): New method.
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.35): Export 8 __cow_string
	symbols.
	* include/bits/new_except.h: New file.
	* include/bits/new_throw.h: New file.
	* include/bits/stdexcept_throw.h: New file.
	* include/bits/stdexcept_throwdef.h: New file.
	* include/bits/stdexcept_throwfwd.h: New file.
	* include/std/stdexcept: Include bits/stdexcept_except.h and move
	everything after <string> include except for std::range_error into
	include/bits/stdexcept_except.h.
	(std::range_error): If __cpp_lib_constexpr_exceptions >= 202502L
	make all cdtors and methods constexpr.
	* include/bits/stdexcept_except.h: New file.
	* include/std/optional (__glibcxx_want_constexpr_exceptions): Define
	before including bits/version.h.
	(bad_optional_access::what): Make constexpr for
	__cpp_lib_constexpr_exceptions >= 202502L.
	(__throw_bad_optional_access): Likewise.
	* include/std/expected (__glibcxx_want_constexpr_exceptions): Define
	before including bits/version.h.
	(bad_expected_access): Make cdtors and all methods constexpr for
	__cpp_lib_constexpr_exceptions >= 202502L.
	* include/std/format (__glibcxx_want_constexpr_exceptions): Define
	before including bits/version.h.
	(_GLIBCXX_CONSTEXPR_FORMAT_ERROR): Define and undef later.
	(format_error): Use _GLIBCXX_CONSTEXPR_FORMAT_ERROR on ctors.
	* include/std/variant (__glibcxx_want_constexpr_exceptions): Define
	before including bits/version.h.
	(_GLIBCXX_CONSTEXPR_BAD_VARIANT_ACCESS): Define and undef later.
	(bad_variant_access): Use it on ctors and what() method.
	(__throw_bad_variant_access): Use it here too.
	* testsuite/18_support/exception/version.cc: Adjust expected
	__cpp_lib_constexpr_exceptions value.
	* testsuite/19_diagnostics/runtime_error/constexpr.cc: New test.
	* testsuite/19_diagnostics/headers/stdexcept/version.cc: New test.
	* testsuite/19_diagnostics/logic_error/constexpr.cc: New test.
	* testsuite/20_util/expected/observers.cc (test_value_throw): Change
	return type to bool from void, return true at the end, add test
	to dereference what() first character.  Make it constexpr for
	__cpp_lib_constexpr_exceptions >= 202502L and add static_assert.
	* testsuite/20_util/expected/version.cc: Add tests for
	__cpp_lib_constexpr_exceptions value.
	* testsuite/20_util/variant/constexpr.cc: For
	__cpp_lib_constexpr_exceptions >= 202502L include <string>.
	(test_get): New function if __cpp_lib_constexpr_exceptions >= 202502L,
	assert calling it is true.
	* testsuite/20_util/variant/version.cc: Add tests for
	__cpp_lib_constexpr_exceptions value.
	* testsuite/20_util/optional/constexpr/observers/3.cc: Include
	testsuite_hooks.h.
	(eat, test01): New functions.  Assert test01() is true.
	* testsuite/20_util/optional/version.cc: Add tests for
	__cpp_lib_constexpr_exceptions value.
	* include/std/future: Add #include <bits/functexcept.h>.
	* include/std/shared_mutex: Include <bits/new_throw.h>.
	* include/std/flat_map: Include <bits/stdexcept_throw.h> instead of
	<bits/functexcept.h>.
	* include/std/syncstream: Remove <bits/functexcept.h> include.
	* include/std/flat_set: Likewise.
	* include/std/bitset: Include <bits/stdexcept_throw.h> instead of
	<bits/functexcept.h>.
	* include/std/string_view: Don't include <bits/functexcept.h>, include
	<bits/stdexcept_throw.h> early if __glibcxx_exc_in_string is not
	defined and include <bits/stdexcept_throw.h> at the end of
	the header again if __glibcxx_exc_in_string is 2 and C++26 constexpr
	exceptions are enabled.
	(__glibcxx_exc_in_string): Define if __glibcxx_exc_in_string wasn't
	defined before including <bits/stdexcept_throw.h>.
	* include/std/array: Include <bits/stdexcept_throw.h> instead of
	<bits/functexcept.h>.
	* include/std/inplace_vector: Likewise.
	* include/std/string: Include <bits/stdexcept_except.h> and
	<bits/stdexcept_throw.h> after bits/basic_string.tcc include if
	C++26 constexpr exceptions are enabled and include
	<bits/stdexcept_throw.h> instead of <bits/functexcept.h> early.
	(__glibcxx_exc_in_string): Define early to 1, undefine at the end.
	* include/std/deque: Include <bits/stdexcept_throw.h>.
	* include/bits/new_allocator.h: Include <bits/new_throw.h> instead
	of <bits/functexcept.h>.
	* include/bits/stl_algobase.h: Remove <bits/functexcept.h> include.
	* include/bits/stl_vector.h: Include <bits/stdexcept_throw.h> instead
	of <bits/functexcept.h>.
	* include/bits/memory_resource.h: Include <bits/new_throw.h> instead
	of <bits/functexcept.h>.
	* include/bits/functexcept.h: Guard everything after includes with
	#if _GLIBCXX_HOSTED.
	(__throw_bad_alloc, __throw_bad_array_new_length,  __throw_logic_error,
	__throw_domain_error, __throw_invalid_argument, __throw_length_error,
	__throw_out_of_range, __throw_out_of_range_fmt, __throw_runtime_error,
	__throw_overflow_error, __throw_underflow_error): Move declarations to
	other headers - <bits/new_throw.h> and <bits/stdexcept_throwfwd.h>.
	* include/bits/stl_map.h: Include <bits/stdexcept_throw.h> instead
	of <bits/functexcept.h>.
	* include/bits/hashtable_policy.h: Include <bits/stdexcept_throw.h>
	instead of <bits/functexcept.h>.
	* include/bits/formatfwd.h (std::__throw_format_error): Remove
	declaration.
	* include/bits/specfun.h: Include <bits/stdexcept_throw.h> instead of
	<bits/functexcept.h>.
	* include/bits/basic_ios.h: Include <bits/functexcept.h>.
	* include/bits/locale_classes.h: Likewise.
	* include/tr1/cmath: Include <bits/stdexcept_throw.h> instead of
	<bits/functexcept.h>.
	* include/tr1/memory: Remove <bits/functexcept.h> include.
	* include/tr1/array: Include <bits/stdexcept_throw.h>.
	* include/ext/vstring_util.h: Include <bits/stdexcept_throw.h> instead
	of <bits/functexcept.h>.
	* include/ext/bitmap_allocator.h: Include <bits/new_throw.h> instead
	of <bits/functexcept.h>.
	* include/ext/mt_allocator.h: Likewise.
	* include/ext/malloc_allocator.h: Likewise.
	* include/ext/debug_allocator.h: Include <bits/stdexcept_throw.h>
	instead of <bits/functexcept.h>.
	* include/ext/concurrence.h: Include <bits/exception_defines.h>
	instead of <bits/functexcept.h>.
	* include/ext/throw_allocator.h: Include <bits/new_throw.h> and
	<bits/stdexcept_throw.h> instead of <bits/functexcept.h>.
	* include/ext/string_conversions.h: Include <bits/stdexcept_throw.h>
	instead of <bits/functexcept.h>.
	* include/ext/pool_allocator.h: Include <bits/new_throw.h> instead
	of <bits/functexcept.h>.
	* include/ext/ropeimpl.h: Include <bits/stdexcept_throw.h> instead of
	<bits/functexcept.h>.
	* include/tr2/dynamic_bitset: Likewise.
	* include/experimental/optional: Include <bits/exception_defines.h>
	instead of <bits/functexcept.h>.
	* include/Makefile.am (bits_freestanding): Add
	${bits_srcdir}/{new,stdexcept}_{except,throw}.h
	and ${bits_srcdir}/stdexcept_throw{fwd,def}.h.
	* include/Makefile.in: Regenerate.
	* src/c++17/floating_from_chars.cc: Remove <bits/functexcept.h>
	include.
	* src/c++11/regex.cc: Likewise.
	* src/c++11/functexcept.cc: Likewise.
	* src/c++11/snprintf_lite.cc: Include <bits/stdexcept_throw.h> instead
	of <bits/functexcept.h>.
	* src/c++11/thread.cc: Include <bits/functexcept.h>.
	* testsuite/util/testsuite_hooks.h: Include <bits/stdexcept_throw.h>
	instead of <bits/functexcept.h>.
	* testsuite/util/io/verified_cmd_line_input.cc: Include
	<bits/exception_defines.h> instead of <bits/functexcept.h>.
	* testsuite/20_util/allocator/105975.cc: Expect different diagnostics
	for C++26.
	* testsuite/23_containers/inplace_vector/access/capacity.cc: Remove
	#error, guard if consteval { return; } with
	#ifndef __cpp_lib_constexpr_exceptions.
	* testsuite/23_containers/inplace_vector/access/elem.cc: Likewise.
	* testsuite/23_containers/inplace_vector/cons/1.cc: Likewise.
	* testsuite/23_containers/inplace_vector/cons/from_range.cc: Likewise.
	* testsuite/23_containers/inplace_vector/modifiers/single_insert.cc:
	Likewise.
	* testsuite/23_containers/inplace_vector/modifiers/assign.cc:
	Likewise.
	* testsuite/23_containers/inplace_vector/modifiers/multi_insert.cc:
	Likewise.
	* libsupc++/new: Include <bits/new_except.h>.
	(std::bad_alloc, std::bad_array_new_length): Move defintion to
	<bits/new_except.h>.
libgomp/
	* omp.h.in: Include <bits/new_throw.h> instead of
	<bits/functexcept.h>.
gcc/testsuite/
	* g++.dg/tree-ssa/pr110819.C: Guard scan-tree-dump-not delete on
	c++23_down and add comment explaining why C++26 fails that.
	* g++.dg/tree-ssa/pr96945.C: Likewise.
	* g++.dg/tree-ssa/pr109442.C: Likewise.
	* g++.dg/tree-ssa/pr116868.C: Likewise.
	* g++.dg/tree-ssa/pr58483.C: Likewise.
2025-12-11 19:54:44 +01:00
Jonathan Wakely
5d8455b072 libstdc++: Move std::cmp_equal, std::cmp_less etc. to new file
This allows the [utility.intcmp] functions to be used without including
all of <utility>.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/std/latch: Include <bits/intcmp.h> instead of
	<utility>.
	* include/std/utility: Include <bits/intcmp.h>.
	(cmp_equal, cmp_not_equal, cmp_less, cmp_greater)
	(cmp_less_equal, cmp_greater_equal, in_range): Move to ...
	* include/bits/intcmp.h: New file.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-12-08 09:15:50 +00:00
François Dumont
8a2e6590cc libstdc++: [_GLIBCXX_DEBUG] Implement std::__debug::inplace_vector
Add _GLIBCXX_DEBUG std::inplace_vector implementation.

libstdc++-v3/ChangeLog:

	* include/Makefile.am (debug_headers): Add inplace_vector.
	* include/Makefile.in: Regenerate.
	* include/debug/functions.h (__check_valid_range): Add C++20 constexpr.
	* include/debug/helper_functions.h (__valid_range): Likewise.
	* include/debug/inplace_vector: New.
	* include/debug/safe_base.h (~_Safe_sequence_base()): Add C++11 noexcept.
	(_Safe_sequence_base::operator=(const _Safe_sequence_base&)): New.
	(_Safe_sequence_base::operator=(_Safe_sequence_base&&)): New.
	(_Safe_sequence_base::_M_invalidate_all): Add C++20 constexpr.
	* include/debug/safe_container.h
	(_Safe_container<>::operator=(const _Safe_container<>&)): Implement using
	_Safe_sequence_base same operator.
	* include/debug/safe_iterator.h (__valid_range): Add C++20 constexpr.
	* include/debug/safe_sequence.h
	(_Not_equal_to(const _Type&)): Add C++20 constexpr.
	(_Equal_to(const _Type&)): Add C++20 constexpr.
	(_After_nth_from(const difference_type&, const _Iterator&)): Add C++20 constexpr.
	(_Safe_sequence<>::_M_invalidate_if): Add C++20 constexpr.
	(_Safe_node_sequence::operator=(const _Safe_node_sequence&)): New.
	(_Safe_node_sequence::operator=(_Safe_node_sequence&&)): New.
	(_Safe_node_sequence<>::_M_invalidate_all()): Add C++20 constexpr.
	* include/debug/safe_sequence.tcc
	(_Safe_sequence<>::_M_invalidate_if): Add C++20 constexpr.
	* include/std/inplace_vector [_GLIBCXX_DEBUG](std::inplace_vector<>): Move
	implementation into __cxx1998 namespace.
	(erase, erase_if): Limit to non-debug inplace_vector<>, cleanup code.
	[_GLIBCXX_DEBUG]: Add include <debug/inplace_vector>.
	* testsuite/23_containers/inplace_vector/cons/1.cc: Adapt, skip several
	is_trivially_xxx checks when in _GLIBCXX_DEBUG mode.
	* testsuite/23_containers/inplace_vector/copy.cc: Likewise.
	* testsuite/23_containers/inplace_vector/move.cc: Likewise.
	* testsuite/23_containers/inplace_vector/debug/assign1_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/assign2_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/assign3_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/assign4_backtrace_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/assign4_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/construct1_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/construct2_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/construct3_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/construct4_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/debug_functions.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/erase.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/insert1_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/insert2_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/insert3_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/insert4_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/insert5_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/insert7_neg.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/1.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/2.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/3.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/4.cc: New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/append_range.cc:
	New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/erase.cc:
	New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/pop_back.cc:
	New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/push_back.cc:
	New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/swap.cc:
	New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/try_append_range.cc:
	New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/try_emplace_back.cc:
	New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/try_push_back.cc:
	New test case.
	* testsuite/23_containers/inplace_vector/debug/invalidation/unchecked_emplace_back.cc:
	New test case.
	* testsuite/util/debug/checks.h: Avoid using _GLIBCXX_DEBUG containers in test
	implementations.
2025-12-03 06:56:27 +01:00
Sam James
ac273977ad *: regenerate autotools
libatomic/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.in: Regenerate.

libcc1/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.

libffi/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* include/Makefile.in: Regenerate.
	* man/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

libgcobol/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.

libgfortran/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.

libgm2/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* libm2cor/Makefile.in: Regenerate.
	* libm2iso/Makefile.in: Regenerate.
	* libm2log/Makefile.in: Regenerate.
	* libm2min/Makefile.in: Regenerate.
	* libm2pim/Makefile.in: Regenerate.

libgomp/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.in: Regenerate.

libgrust/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* libformat_parser/Makefile.in: Regenerate.
	* libproc_macro_internal/Makefile.in: Regenerate.

libitm/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.in: Regenerate.

libobjc/ChangeLog:

	* aclocal.m4: Regenerate.
	* configure: Regenerate.

libphobos/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* libdruntime/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

libquadmath/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.

libsanitizer/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* asan/Makefile.in: Regenerate.
	* configure: Regenerate.
	* hwasan/Makefile.in: Regenerate.
	* interception/Makefile.in: Regenerate.
	* libbacktrace/Makefile.in: Regenerate.
	* lsan/Makefile.in: Regenerate.
	* sanitizer_common/Makefile.in: Regenerate.
	* tsan/Makefile.in: Regenerate.
	* ubsan/Makefile.in: Regenerate.

libssp/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* 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++20/Makefile.in: Regenerate.
	* src/c++23/Makefile.in: Regenerate.
	* src/c++26/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/experimental/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

libvtv/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.in: Regenerate.

lto-plugin/ChangeLog:

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
2025-10-05 17:14:49 +01:00
Jonathan Wakely
0959f0e0ce libstdc++: Remove unwanted STDC_HEADERS macro from c++config.h [PR79147]
Similar to r16-4034-g1953939243e1ab, this comments out another macro
that Autoconf adds to the generated config.h but which is not wanted in
the c++config.h file that we install.

There's no benefit to defining _GLIBCXX_STDC_HEADERS in user code, so we
should just prevent it from being defined.

libstdc++-v3/ChangeLog:

	PR libstdc++/79147
	PR libstdc++/103650
	* include/Makefile.am (c++config.h): Adjust sed command to
	comment out STDC_HEADERS macro.
	* include/Makefile.in: Regenerate.
2025-09-25 14:51:50 +01:00
Jonathan Wakely
1953939243 libstdc++: Remove unwanted PACKAGE macros from c++config.h [PR79147]
Autoconf insists on adding macros like PACKAGE_NAME and
PACKAGE_BUG_TARNAME to config.h but those are useless for libstdc++
because it's not a complete package, just a sub-directory of gcc, and we
never use any of those strings in our sources.

Since we include the generated config.h in our installed c++config.h
header, those useless macros are exposed to users. We do transform them
to use the reserved _GLIBCXX_ prefix, but they're still just useless
noise in the installed header.

I don't know any way to get autoconf to not add them to config.h but
this change comments them out so they're not defined when users include
our headers.

Although not really important now that the macro isn't being defined,
this change also avoids the double substitution for PACKAGE_VERSION
which was resulting in _GLIBCXX_PACKAGE__GLIBCXX_VERSION.

libstdc++-v3/ChangeLog:

	PR libstdc++/79147
	* include/Makefile.am (c++config.h): Adjust sed command to
	comment out all PACKAGE_XXX macros and to avoid adjusting
	PACKAGE_VERSION twice.
	* include/Makefile.in: Regenerate.
2025-09-23 10:17:09 +01:00
Tomasz Kamiński
b2adb7712c libstdc++: Move _Binder and related aliases to separate file.
bits/binders.h is already mapped in libstdc++-v3/doc/doxygen/stdheader.cc.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add bits/binders.h
	* include/Makefile.in: Add bits/binders.h
	* include/std/functional (std::_Indexed_bound_arg, std::_Binder)
	(std::__make_bound_args, std::_Bind_front_t, std::_Bind_back_t):
	Moved to bits/binders.h file, that is now included.
	* include/bits/binders.h: New file.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-09-04 15:29:36 +02:00
Jonathan Wakely
3c95766e92 libstdc++: Implement C++26 <debugging> features [PR119670]
This implements P2546R5 (Debugging Support), including the P2810R4
(is_debugger_present is_replaceable) changes, allowing
std::is_debugger_present to be replaced by the program.

It would be good to provide a macOS definition of is_debugger_present as
per https://developer.apple.com/library/archive/qa/qa1361/_index.html
but that isn't included in this change.

The src/c++26/debugging.cc file defines a global volatile int which can
be set by debuggers to indicate when they are attached and detached from
a running process. This allows std::is_debugger_present() to give a
reliable answer, and additionally allows a debugger to choose how
std::breakpoint() should behave. Setting the global to a positive value
will cause std::breakpoint() to use that value as an argument to
std::raise, so debuggers that prefer SIGABRT for breakpoints can select
that. By default std::breakpoint() will use a platform-specific action
such as the INT3 instruction on x86, or GCC's __builtin_trap().

On Linux the std::is_debugger_present() function checks whether the
process is being traced by a process named "gdb", "gdbserver" or
"lldb-server", to try to avoid interpreting other tracing processes
(such as strace) as a debugger. There have been comments suggesting this
isn't desirable and that std::is_debugger_present() should just return
true for any tracing process (which is the case for non-Linux targets
that support the ptrace system call).

libstdc++-v3/ChangeLog:

	PR libstdc++/119670
	* acinclude.m4 (GLIBCXX_CHECK_DEBUGGING): Check for facilities
	needed by <debugging>.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Use GLIBCXX_CHECK_DEBUGGING.
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/version.def (debugging): Add.
	* include/bits/version.h: Regenerate.
	* include/precompiled/stdc++.h: Add new header.
	* src/c++26/Makefile.am: Add new file.
	* src/c++26/Makefile.in: Regenerate.
	* include/std/debugging: New file.
	* src/c++26/debugging.cc: New file.
	* testsuite/19_diagnostics/debugging/breakpoint.cc: New test.
	* testsuite/19_diagnostics/debugging/breakpoint_if_debugging.cc:
	New test.
	* testsuite/19_diagnostics/debugging/is_debugger_present.cc: New
	test.
	* testsuite/19_diagnostics/debugging/is_debugger_present-2.cc:
	New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-08-28 17:47:00 +01:00
Jonathan Wakely
9e33097738 libstdc++: Add std::inplace_vector for C++26 (P0843R14) [PR119137]
Implement std::inplace_vector as specified in P0843R14, without follow
up papers, in particular P3074R7 (trivial unions). In consequence
inplace_vector<T, N> can be used inside constant evaluations only
if T is trivial or N is equal to zero.

We provide a separate specialization for inplace_vector<T, 0> to meet
the requirements of N5008 [inplace.vector.overview] p5. In particular
objects of such types needs to be empty.

To allow constexpr variable of inplace_vector v, where v.size() < v.capacity(),
we need to guaranteed that all elements of the storage array are initialized,
even ones in range [v.data() + v.size(), v.data() + v.capacity()). This is
perfoirmed by _M_init function, that is called by each constructor. By storing
the array in anonymous union, we can perform this initialization in constant
evaluation, avoiding the impact on runtime path.

The size() function conveys the information that _M_size <= _Nm to compiler,
by calling __builtin_unreachable(). In particular this allows us to eliminate
FP warnings by using _Nm - size() instead of _Nm - _M_size, when computing
available elements.

The included test cover almost all code paths at runtime, however some
compile time evaluation test are not yet implemented:
* operations on range, they depend on making testsuite_iterators constexpr
* negative test for invoking operations with preconditions at compile time,
  especially for zero size specialization.

	PR libstdc++/119137

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (INPUT): Add new header.
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/stl_iterator_base_types.h (__any_input_iterator):
	Define.
	* include/bits/version.def (inplace_vector): Define.
	* include/bits/version.h: Regenerate.
	* include/precompiled/stdc++.h: Include new header.
	* src/c++23/std.cc.in: Export contents if new header.
	* include/std/inplace_vector: New file.
	* testsuite/23_containers/inplace_vector/access/capacity.cc: New file.
	* testsuite/23_containers/inplace_vector/access/elem.cc: New file.
	* testsuite/23_containers/inplace_vector/access/elem_neg.cc: New file.
	* testsuite/23_containers/inplace_vector/cons/1.cc: New file.
	* testsuite/23_containers/inplace_vector/cons/from_range.cc: New file.
	* testsuite/23_containers/inplace_vector/cons/throws.cc: New file.
	* testsuite/23_containers/inplace_vector/copy.cc: New file.
	* testsuite/23_containers/inplace_vector/erasure.cc: New file.
	* testsuite/23_containers/inplace_vector/modifiers/assign.cc: New file.
	* testsuite/23_containers/inplace_vector/modifiers/erase.cc: New file.
	* testsuite/23_containers/inplace_vector/modifiers/multi_insert.cc:
	New file.
	* testsuite/23_containers/inplace_vector/modifiers/single_insert.cc:
	New file.
	* testsuite/23_containers/inplace_vector/move.cc: New file.
	* testsuite/23_containers/inplace_vector/relops.cc: New file.
	* testsuite/23_containers/inplace_vector/version.cc: New file.
	* testsuite/util/testsuite_iterators.h (input_iterator_wrapper::base):
	Define.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-07-18 09:49:34 +02:00
Jonathan Wakely
324aad35ef libstdc++: Regenerate include/Makefile.in
libstdc++-v3/ChangeLog:

	* include/Makefile.in: Regenerate.
2025-05-27 13:35:23 +01:00
Jonathan Wakely
caf804b179 libstdc++: Implement C++26 std::indirect [PR119152]
This patch implements C++26 std::indirect as specified
in P3019 with amendment to move assignment from LWG 4251.

	PR libstdc++/119152

libstdc++-v3/ChangeLog:

	* doc/doxygen/stdheader.cc: Added indirect.h file.
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/indirect.h: New file.
	* include/bits/version.def (indirect): Define.
	* include/bits/version.h: Regenerate.
	* include/std/memory: Include new header.
	* testsuite/std/memory/indirect/copy.cc
	* testsuite/std/memory/indirect/copy_alloc.cc
	* testsuite/std/memory/indirect/ctor.cc
	* testsuite/std/memory/indirect/incomplete.cc
	* testsuite/std/memory/indirect/invalid_neg.cc
	* testsuite/std/memory/indirect/move.cc
	* testsuite/std/memory/indirect/move_alloc.cc
	* testsuite/std/memory/indirect/relops.cc

Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-05-26 12:25:32 +02:00
Tomasz Kamiński
545433e9bd libstdc++: Implement C++26 function_ref [PR119126]
This patch implements C++26 function_ref as specified in P0792R14,
with correction for constraints for constructor accepting nontype_t
parameter from LWG 4256.

As function_ref may store a pointer to the const object, __Ptrs::_M_obj is
changed to const void*, so again we do not cast away const from const
objects. To help with necessary casts, a __polyfunc::__cast_to helper is
added, that accepts reference to or target type direclty.

The _Invoker now defines additional call methods used by function_ref:
_S_ptrs() for invoking target passed by reference, and __S_nttp, _S_bind_ptr,
_S_bind_ref for handling constructors accepting nontype_t. The existing
_S_call_storage is changed to thin wrapper, that initialies _Ptrs, and forwards
to _S_call_ptrs.

This reduced the most uses of _Storage::_M_ptr and _Storage::_M_ref,
so this functions was removed, and _Manager uses were adjusted.

Finally we make function_ref available in freestanding mode, as
move_only_function and copyable_function are currently only available in hosted,
so we define _Manager and _Mo_base only if either __glibcxx_move_only_function
or __glibcxx_copyable_function is defined.

	PR libstdc++/119126

libstdc++-v3/ChangeLog:

	* doc/doxygen/stdheader.cc: Added funcref_impl.h file.
	* include/Makefile.am: Added funcref_impl.h file.
	* include/Makefile.in: Added funcref_impl.h file.
	* include/bits/funcref_impl.h: New file.
	* include/bits/funcwrap.h: (_Ptrs::_M_obj): Const-qualify.
	(_Storage::_M_ptr, _Storage::_M_ref): Remove.
	(__polyfunc::__cast_to) Define.
	(_Base_invoker::_S_ptrs, _Base_invoker::_S_nttp)
	(_Base_invoker::_S_bind_ptrs, _Base_invoker::_S_bind_ref)
	(_Base_invoker::_S_call_ptrs): Define.
	(_Base_invoker::_S_call_storage): Foward to _S_call_ptrs.
	(_Manager::_S_local, _Manager::_S_ptr): Adjust for _M_obj being
	const qualified.
	(__polyfunc::_Manager, __polyfunc::_Mo_base): Guard with
	__glibcxx_move_only_function || __glibcxx_copyable_function.
	(__polyfunc::__skip_first_arg, __polyfunc::__deduce_funcref)
	(std::function_ref) [__glibcxx_function_ref]: Define.
	* include/bits/utility.h (std::nontype_t, std::nontype)
	(__is_nontype_v) [__glibcxx_function_ref]: Define.
	* include/bits/version.def: Define function_ref.
	* include/bits/version.h: Regenerate.
	* include/std/functional: Define __cpp_lib_function_ref.
	* src/c++23/std.cc.in (std::nontype_t, std::nontype)
	(std::function_ref) [__cpp_lib_function_ref]: Export.
	* testsuite/20_util/function_ref/assign.cc: New test.
	* testsuite/20_util/function_ref/call.cc: New test.
	* testsuite/20_util/function_ref/cons.cc: New test.
	* testsuite/20_util/function_ref/cons_neg.cc: New test.
	* testsuite/20_util/function_ref/conv.cc: New test.
	* testsuite/20_util/function_ref/deduction.cc: New test.
	* testsuite/20_util/function_ref/mutation.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-05-26 11:25:28 +02:00
Tomasz Kamiński
d9055d0104 libstdc++: Renamed bits/move_only_function.h to bits/funcwrap.h [PR119125]
The file now includes copyable_function in addition to
move_only_function.

	PR libstdc++/119125

libstdc++-v3/ChangeLog:
	* include/bits/move_only_function.h: Move to...
	* include/bits/funcwrap.h: ...here.
	* doc/doxygen/stdheader.cc (init_map): Replaced move_only_function.h
	with funcwrap.h, and changed include guard to use feature test macro.
	Move bits/version.h include before others.
	* include/Makefile.am: Likewise.
	* include/Makefile.in: Likewise.
	* include/std/functional: Likewise.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-05-14 15:00:41 +02:00
Tomasz Kamiński
0e93f7cd4e libstdc++: Implement C++26 copyable_function [PR119125]
This patch implements C++26 copyable_function as specified in P2548R6.
It also implements LWG 4255 that adjust move_only_function so constructing
from empty copyable_function, produces empty functor. This falls from
existing checks, after specializing __is_polymorphic_function_v for
copyable_function specializations.

For compatible invoker signatures, the move_only_function may be constructed
from copyable_funciton without double indirection. To achieve that we derive
_Cpy_base from _Mo_base, and specialize __is_polymorphic_function_v for
copyable_function. Similary copyable_functions with compatible signatures
can be converted without double indirection.

As we starting to use _Op::_Copy operation from the _M_manage function,
invocations of that functions may now throw exceptions, so noexcept needs
to be removed from the signature of stored _M_manage pointers. This also
affects operations in _Mo_base, however we already wrap _M_manage invocations
in noexcept member functions (_M_move, _M_destroy, swap).

	PR libstdc++/119125

libstdc++-v3/ChangeLog:

	* doc/doxygen/stdheader.cc: Addded cpyfunc_impl.h header.
	* include/Makefile.am: Add bits cpyfunc_impl.h.
	* include/Makefile.in: Add bits cpyfunc_impl.h.
	* include/bits/cpyfunc_impl.h: New file.
	* include/bits/mofunc_impl.h: Mention LWG 4255.
	* include/bits/move_only_function.h: Update header description
	and change guard to also check __glibcxx_copyable_function.
	(_Manager::_Func): Remove noexcept.
	(std::__is_polymorphic_function_v<move_only_function<_Tp>>)
	(__variant::_Never_valueless_alt<std::move_only_function<_Signature...>>)
	(move_only_function) [__glibcxx_move_only_function]: Adjust guard.
	(std::__is_polymorphic_function_v<copyable_function<_Tp>>)
	(__variant::_Never_valueless_alt<std::copyable_function<_Signature...>>)
	(__polyfunc::_Cpy_base, std::copyable_function)
	[__glibcxx_copyable_function]: Define.
	* include/bits/version.def: Define copyable_function.
	* include/bits/version.h: Regenerate.
	* include/std/functional: Define __cpp_lib_copyable_function.
	* src/c++23/std.cc.in (copyable_function)
	[__cpp_lib_copyable_function]: Export.
	* testsuite/20_util/copyable_function/call.cc: New test based on
	move_only_function tests.
	* testsuite/20_util/copyable_function/cons.cc: New test based on
	move_only_function tests.
	* testsuite/20_util/copyable_function/conv.cc: New test based on
	move_only_function tests.
	* testsuite/20_util/copyable_function/copy.cc: New test.
	* testsuite/20_util/copyable_function/move.cc: New test based on
	move_only_function tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-05-14 14:00:47 +02:00
Luc Grosheintz
4c9eef71db libstdc++: Add header mdspan to the build-system.
Creates a nearly empty header mdspan and adds it to the build-system and
Doxygen config file.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in: Add <mdspan>.
	* include/Makefile.am: Ditto.
	* include/Makefile.in: Ditto.
	* include/precompiled/stdc++.h: Ditto.
	* include/std/mdspan: New file.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2025-05-07 11:47:39 +01:00
Tomasz Kamiński
84d668b0ca libstdc++: Provide formatter for vector<bool>::reference [PR109162]
This patch implement formatter for vector<bool>::reference which
is part of P2286R8.

To indicate partial support we define __glibcxx_format_ranges macro
value 1, without defining __cpp_lib_format_ranges.

To avoid including the whole content of the <format> header, we
introduce new bits/formatfwd.h forward declares classes required
for newly introduce formatter.

The signatures of the user-facing parse and format method of the provided
formatters deviate from the standard by constraining types of params:
* _Bit_reference instead T satisfying is-vector-bool-reference<T>
* _CharT is constrained __formatter::__char
* basic_format_parse_context<_CharT> for parse argument
* basic_format_context<_Out, _CharT> for format second argument
The standard specifies last three of above as unconstrained types, which leads
to formattable<vector<bool>::reference, char32_t> (and any other type as char)
being true.

	PR libstdc++/109162

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add bits/formatfwd.h.
	* include/Makefile.in: Add bits/formatfwd.h.
	* include/bits/version.def: Define __glibcxx_format_ranges without
	corresponding std name.
	* include/bits/version.h: Regenerate.
	* include/std/format (basic_format_context, __format::__char):
	Move declartions to bits/formatfwd.h.
	(formatter<_Tp, _CharT>): Remove default argument for _CharT
	parameter, now specified in forward declaration in bits/formatfwd.h.
	* include/std/vector (formatter<_Bit_reference, _CharT>): Define.
	* include/bits/formatfwd.h: New file with forward declarations
	for bits of std/format.
	* testsuite/23_containers/vector/bool/format.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-04 13:03:34 +02:00
Jonathan Wakely
d4c7de7dc9 libstdc++: Implement <stdckdint.h> for C++26 (P3370R1)
This is the second part of the P3370R1 proposal just approved by the
committee in Wrocław. This adds C++ equivalents of the functions added
to C23 by WG14 N2683.

These functions are in the global namespace, but to avoid collisions
with the same functions defined by other standard library
implementations, this change defines them in namespace __gnu_cxx and
then adds them to the global namespace.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add stdckdint.h.
	* include/Makefile.in: Regenerate.
	* src/c++23/std.compat.cc.in: Export <stdckdint.h> functions.
	* include/c_compatibility/stdckdint.h: New file.
	* testsuite/26_numerics/stdckdint/1.cc: New test.
	* testsuite/26_numerics/stdckdint/2_neg.cc: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
2025-03-13 14:45:38 +00:00
Jonathan Wakely
7ee31bc927 libstdc++: Implement <stdbit.h> for C++26 (P3370R1)
This is the first part of the P3370R1 proposal just approved by the
committee in Wrocław. This adds C++ equivalents of the functions added
to C23 by WG14 N3022.

These functions are in the global namespace, but to avoid collisions
with the same functions defined by other standard library
implementations, this change defines them in namespace __gnu_cxx and
then adds them to the global namespace.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add stdbit.h.
	* include/Makefile.in: Regenerate.
	* src/c++23/std.compat.cc.in: Export <stdbit.h> functions.
	* include/c_compatibility/stdbit.h: New file.
	* testsuite/20_util/stdbit/1.cc: New test.
	* testsuite/20_util/stdbit/2_neg.cc: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
2025-03-13 14:45:22 +00:00
Jonathan Wakely
462a7f45ca libstdc++: Move std::basic_ostream to new internal header [PR99995]
This adds <bits/ostream.h> so that other headers don't need to include
all of <ostream>, which pulls in all of <format> since C++23 (for the
std::print and std::println overloads in <ostream>). This new header
allows the constrained operator<< in <bits/unique_ptr.h> to be defined
without all of std::format being compiled.

We could also replace <ostream> with <bits/ostream.h> in all of
<istream>, <fstream>, <sstream>, and <spanstream>. That seems more
likely to cause problems for users who might be expecting <sstream> to
define std::endl, for example. Although the standard doesn't guarantee
that, it is more reasonable than expecting <memory> to define it! We can
look into making those changes for GCC 16.

libstdc++-v3/ChangeLog:

	PR libstdc++/99995
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/unique_ptr.h: Include bits/ostream.h instead of
	ostream.
	* include/std/ostream: Include new header.
	* include/bits/ostream.h: New file.
2025-01-16 09:41:00 +00:00
Patrick Palka
e3fab34506 libstdc++: Implement C++23 <flat_set> (P1222R4)
This implements the C++23 container adaptors std::flat_set and
std::flat_multiset from P1222R4.  The implementation is essentially
an simpler and pared down version of std::flat_map.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header <flat_set>.
	* include/Makefile.in: Regenerate.
	* include/bits/version.def (__cpp_flat_set): Define.
	* include/bits/version.h: Regenerate
	* include/precompiled/stdc++.h: Include <flat_set>.
	* include/std/flat_set: New file.
	* src/c++23/std.cc.in: Export <flat_set>.
	* testsuite/23_containers/flat_multiset/1.cc: New test.
	* testsuite/23_containers/flat_set/1.cc: New test.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-12-19 11:31:19 -05:00
Patrick Palka
92381894b3 libstdc++: Implement C++23 <flat_map> (P0429R9)
This implements the C++23 container adaptors std::flat_map and
std::flat_multimap from P0429R9.  The implementation is shared
as much as possible between the two adaptors via a common base
class that's parameterized according to key uniqueness.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header <flat_map>.
	* include/Makefile.in: Regenerate.
	* include/bits/alloc_traits.h (__not_allocator_like): New concept.
	* include/bits/stl_function.h (__transparent_comparator): Likewise.
	* include/bits/stl_iterator_base_types.h (__has_input_iter_cat):
	Likewise.
	* include/bits/uses_allocator.h (__allocator_for): Likewise.
	* include/bits/utility.h (sorted_unique_t): Define for C++23.
	(sorted_unique): Likewise.
	(sorted_equivalent_t): Likewise.
	(sorted_equivalent): Likewise.
	* include/bits/version.def (flat_map): Define.
	* include/bits/version.h: Regenerate.
	* include/precompiled/stdc++.h: Include <flat_map>.
	* include/std/flat_map: New file.
	* src/c++23/std.cc.in: Export <flat_map>.
	* testsuite/23_containers/flat_map/1.cc: New test.
	* testsuite/23_containers/flat_multimap/1.cc: New test.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-12-19 11:31:09 -05:00
Jonathan Wakely
91f4550e17 libstdc++: Move std::monostate to <utility> for C++26 (P0472R2)
Another C++26 paper just approved in Wrocław. The std::monostate class
is defined in <variant> since C++17, but for C++26 it should also be
available in <utility>.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add bits/monostate.h.
	* include/Makefile.in: Regenerate.
	* include/std/utility: Include <bits/monostate.h>.
	* include/std/variant (monostate, hash<monostate>): Move
	definitions to ...
	* include/bits/monostate.h: New file.
	* testsuite/20_util/headers/utility/synopsis.cc: Add monostate
	and hash<monostate> declarations.
	* testsuite/20_util/monostate/requirements.cc: New test.
2024-11-30 21:39:16 +00:00
Srinivas Yadav Singanaboina
9ac3119fec libstdc++: add ARM SVE support to std::experimental::simd
libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add simd_sve.h.
	* include/Makefile.in: Add simd_sve.h.
	* include/experimental/bits/simd.h: Add new SveAbi.
	* include/experimental/bits/simd_builtin.h: Use
	__no_sve_deduce_t to support existing Neon Abi.
	* include/experimental/bits/simd_converter.h: Convert
	sequentially when sve is available.
	* include/experimental/bits/simd_detail.h: Define sve
	specific macro.
	* include/experimental/bits/simd_math.h: Fallback frexp
	to execute sequntially when sve is available, to handle
	fixed_size_simd return type that always uses sve.
	* include/experimental/simd: Include bits/simd_sve.h.
	* testsuite/experimental/simd/tests/bits/main.h: Enable
	testing for sve128, sve256, sve512.
	* include/experimental/bits/simd_sve.h: New file.

Signed-off-by: Srinivas Yadav Singanaboina <vasu.srinivasvasu.14@gmail.com>
2024-03-27 15:14:36 +01:00
Jonathan Wakely
90788dd722 libstdc++: Regenerate <bits/version.h> in maintainer mode
This is a generated header but regenerating it requires the manual step
of running 'make -C include update-version' in the libstdc++ build dir.
Make it regenerate automatically when --enable-maintainer-mode is used.

libstdc++-v3/ChangeLog:

	* include/Makefile.am [MAINTAINER_MODE]: Add target to
	automatically update <bits/version.h>.
	* include/Makefile.in: Regenerate.

gcc/ChangeLog:

	* doc/install.texi (Prerequisites): Document use of autogen for
	libstdc++.
2024-03-19 15:20:07 +00:00
Jonathan Wakely
df0a668b78 libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318]
This is another C++26 change, approved in Varna 2023. We require a new
static array of data that is extracted from the IANA Character Sets
database. A new Python script to generate a header from the IANA CSV
file is added.

The text_encoding class is basically just a pointer to an {ID,name} pair
in the static array. The aliases view is also just the same pointer (or
empty), and the view's iterator moves forwards and backwards in the
array while the array elements have the same ID (or to one element
further, for a past-the-end iterator).

Because those iterators refer to a global array that never goes out of
scope, there's no reason they should every produce undefined behaviour
or indeterminate values.  They should either have well-defined
behaviour, or abort. The overhead of ensuring those properties is pretty
low, so seems worth it.

This means that an aliases_view iterator should never be able to access
out-of-bounds. A non-value-initialized iterator always points to an
element of the static array even when not dereferenceable (the array has
unreachable entries at the start and end, which means that even a
past-the-end iterator for the last encoding in the array still points to
valid memory).  Dereferencing an iterator can always return a valid
array element, or "" for a non-dereferenceable iterator (but doing so
will abort when assertions are enabled).  In the language being proposed
for C++26, dereferencing an invalid iterator erroneously returns "".
Attempting to increment/decrement past the last/first element in the
view is erroneously a no-op, so aborts when assertions are enabled, and
doesn't change value otherwise.

Similarly, constructing a std::text_encoding with an invalid id (one
that doesn't have the value of an enumerator) erroneously behaves the
same as constructing with id::unknown, or aborts with assertions
enabled.

libstdc++-v3/ChangeLog:

	PR libstdc++/113318
	* acinclude.m4 (GLIBCXX_CONFIGURE): Add c++26 directory.
	(GLIBCXX_CHECK_TEXT_ENCODING): Define.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Use GLIBCXX_CHECK_TEXT_ENCODING.
	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* include/bits/locale_classes.h (locale::encoding): Declare new
	member function.
	* include/bits/unicode.h (__charset_alias_match): New function.
	* include/bits/text_encoding-data.h: New file.
	* include/bits/version.def (text_encoding): Define.
	* include/bits/version.h: Regenerate.
	* include/std/text_encoding: New file.
	* src/Makefile.am: Add new subdirectory.
	* src/Makefile.in: Regenerate.
	* src/c++26/Makefile.am: New file.
	* src/c++26/Makefile.in: New file.
	* src/c++26/text_encoding.cc: New file.
	* src/experimental/Makefile.am: Include c++26 convenience
	library.
	* src/experimental/Makefile.in: Regenerate.
	* python/libstdcxx/v6/printers.py (StdTextEncodingPrinter): New
	printer.
	* scripts/gen_text_encoding_data.py: New file.
	* testsuite/22_locale/locale/encoding.cc: New test.
	* testsuite/ext/unicode/charset_alias_match.cc: New test.
	* testsuite/std/text_encoding/cons.cc: New test.
	* testsuite/std/text_encoding/members.cc: New test.
	* testsuite/std/text_encoding/requirements.cc: New test.

Reviewed-by: Ulrich Drepper <drepper.fsp@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
2024-01-17 11:49:11 +00:00
Jonathan Wakely
37a4c5c23a libstdc++: Add Unicode-aware width estimation for std::format
This implements the requirements in the following proposals, which
dictate how std::format deals with non-ASCII strings:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1868r1.html
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2572r1.html
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2675r1.pdf

There are two parts to this. The width estimation for strings must only
count the width of the first character in an extended grapheme cluster.
That requires implementing the algorithm for detecting cluster breaks,
which requires a number of lookup tables of the grapheme cluster break
properties (and Indic_Conjunct_Break and Extended_Pictographic
properties) of every code point. Additionally, some characters have a
field width of 2, which requires another lookup table of field widths
for every code point.  The tables added in this commit do not contain
entries for every code point from 0 to 0x10FFFF as that would be very
inefficient and use too much memory. Instead the tables only contain the
code points that form an "edge" for a property, omitting all the code
points that have the same property as the preceding one. We can use a
binary search to find the closest code point in the table that is not
greater than the one we're looking for.

The tables are generated by a new Python script added to the
contrib/unicode directory, and a new data file downloaded from the
Unicode Consortium website.

The rules for extended grapheme cluster breaking are implemented for the
latest Unicode standard, version 15.1.0.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* include/bits/unicode.h: New file.
	* include/bits/unicode-data.h: New file.
	* include/std/format: Include <bits/unicode.h>.
	(__literal_encoding_is_utf8): Move to <bits/unicode.h>.
	(_Spec::_M_fill): Change type to char32_t.
	(_Spec::_M_parse_fill_and_align): Read a Unicode scalar value
	instead of a single character.
	(__write_padded): Change __fill_char parameter to char32_t and
	encode it into the output.
	(__formatter_str::format): Use new __unicode::__field_width and
	__unicode::__truncate functions.
	* include/std/ostream: Adjust namespace qualification for
	__literal_encoding_is_utf8.
	* include/std/print: Likewise.
	* src/c++23/print.cc: Add [[unlikely]] attribute to error path.
	* testsuite/ext/unicode/view.cc: New test.
	* testsuite/std/format/functions/format.cc: Add missing examples
	from the standard demonstrating alignment with non-ASCII
	characters. Add examples checking correct handling of extended
	grapheme clusters.

contrib/ChangeLog:

	* unicode/README: Add notes about generating libstdc++ tables.
	* unicode/GraphemeBreakProperty.txt: New file.
	* unicode/emoji-data.txt: New file.
	* unicode/gen_libstdcxx_unicode_data.py: New file.
2024-01-08 01:14:50 +00:00
Arsen Arsenović
ec2ec24a4d libstdc++: implement std::generator
libstdc++-v3/ChangeLog:

	* include/Makefile.am: Install std/generator, bits/elements_of.h
	as freestanding.
	* include/Makefile.in: Regenerate.
	* include/bits/version.def: Add __cpp_lib_generator.
	* include/bits/version.h: Regenerate.
	* include/precompiled/stdc++.h: Include <generator>.
	* include/std/ranges: Include bits/elements_of.h
	* include/bits/elements_of.h: New file.
	* include/std/generator: New file.
	* testsuite/24_iterators/range_generators/01.cc: New test.
	* testsuite/24_iterators/range_generators/02.cc: New test.
	* testsuite/24_iterators/range_generators/copy.cc: New test.
	* testsuite/24_iterators/range_generators/except.cc: New test.
	* testsuite/24_iterators/range_generators/synopsis.cc: New test.
	* testsuite/24_iterators/range_generators/subrange.cc: New test.
2023-12-21 22:59:22 +01:00
Jonathan Wakely
fe54b57728 libstdc++: Implement C++23 <print> header [PR107760]
This adds the C++23 std::print functions, which use std::format to write
to a FILE stream or std::ostream (defaulting to stdout).

The new extern symbols are in the libstdc++exp.a archive, so we aren't
committing to stable symbols in the DSO yet. There's a UTF-8 validating
and transcoding function added by this change. That can certainly be
optimized, but it's internal to libstdc++exp.a so can be tweaked later
at leisure.

Currently the external symbols work for all targets, but are only
actually used for Windows, where it's necessary to transcode to UTF-16
to write to the console.  The standard seems to encourage us to also
diagnose invalid UTF-8 for non-Windows targets when writing to a
terminal (and only when writing to a terminal), but I'm reliably
informed that that wasn't the intent of the wording. Checking for
invalid UTF-8 sequences only needs to happen for Windows, which is good
as checking for a terminal requires a call to isatty, and on Linux that
uses an ioctl syscall, which would make std::print ten times slower!

Testing the std::print behaviour is difficult if it depends on whether
the output stream is connected to a Windows console or not, as we can't
(as far as I know) do that non-interactively in DejaGNU. One of the new
tests uses the internal __write_to_terminal function directly. That
allows us to verify its UTF-8 error handling on POSIX targets, even
though that's not actually used by std::print. For Windows, that
__write_to_terminal function transcodes to UTF-16 but then uses
WriteConsoleW which fails unless it really is writing to the console.
That means the 27_io/print/2.cc test FAILs on Windows. The UTF-16
transcoding has been manually tested using mingw-w64 and Wine, and
appears to work.

libstdc++-v3/ChangeLog:

	PR libstdc++/107760
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/version.def (__cpp_lib_print): Define.
	* include/bits/version.h: Regenerate.
	* include/std/format (__literal_encoding_is_utf8): New function.
	(_Seq_sink::view()): New member function.
	* include/std/ostream (vprintf_nonunicode, vprintf_unicode)
	(print, println): New functions.
	* include/std/print: New file.
	* src/c++23/Makefile.am: Add new source file.
	* src/c++23/Makefile.in: Regenerate.
	* src/c++23/print.cc: New file.
	* testsuite/27_io/basic_ostream/print/1.cc: New test.
	* testsuite/27_io/print/1.cc: New test.
	* testsuite/27_io/print/2.cc: New test.
2023-12-14 23:59:24 +00:00
Jonathan Wakely
568eb2d25c libstdc++: Define C++26 saturation arithmetic functions (P0543R3)
This was approved for C++26 last week at the WG21 meeting in Kona.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/version.def (saturation_arithmetic): Define.
	* include/bits/version.h: Regenerate.
	* include/std/numeric: Include new header.
	* include/bits/sat_arith.h: New file.
	* testsuite/26_numerics/saturation/add.cc: New test.
	* testsuite/26_numerics/saturation/cast.cc: New test.
	* testsuite/26_numerics/saturation/div.cc: New test.
	* testsuite/26_numerics/saturation/mul.cc: New test.
	* testsuite/26_numerics/saturation/sub.cc: New test.
	* testsuite/26_numerics/saturation/version.cc: New test.
2023-11-17 15:28:30 +00:00
Jonathan Wakely
c7f6537db9 libstdc++: Implement std::out_ptr and std::inout_ptr for C++23 [PR111667]
This implements that changes from P1132R8, including optimized paths for
std::shared_ptr and std::unique_ptr.

For std::shared_ptr we pre-allocate a new control block in the
std::out_ptr_t constructor so that the destructor is non-throwing. This
requires some care because unlike the shared_ptr(Y*, D, A) constructor,
we don't want to invoke the deleter if allocating the control block
throws, because we don't own any pointer yet. In order to avoid the
unwanted deleter invocation, we create the control block manually. We
also want to avoid invoking the deleter on a null pointer on
destruction, so we destroy the control block manually if there is no
pointer to take ownership of.

For std::unique_ptr and for raw pointers, the out_ptr_t object hands out
direct access to the pointer, so that we don't have anything to do
(except possibly assign a new deleter) in the ~out_ptr_t destructor.

These optimizations avoid requiring additional temporary storage for the
pointer (and optional arguments), and avoid additional instructions to
copy that pointer into the smart pointer at the end.

libstdc++-v3/ChangeLog:

	PR libstdc++/111667
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/out_ptr.h: New file.
	* include/bits/shared_ptr.h (__is_shared_ptr): Move definition
	to here ...
	* include/bits/shared_ptr_atomic.h (__is_shared_ptr): ... from
	here.
	* include/bits/shared_ptr_base.h (__shared_count): Declare
	out_ptr_t as a friend.
	(_Sp_counted_deleter, __shared_ptr): Likewise.
	* include/bits/unique_ptr.h (unique_ptr, unique_ptr<T[], D>):
	Declare out_ptr_t and inout_ptr_t as friends.
	(__is_unique_ptr): Define new variable template.
	* include/bits/version.def (out_ptr): Define.
	* include/bits/version.h: Regenerate.
	* include/std/memory: Include new header.
	* testsuite/20_util/smartptr.adapt/inout_ptr/1.cc: New test.
	* testsuite/20_util/smartptr.adapt/inout_ptr/2.cc: New test.
	* testsuite/20_util/smartptr.adapt/inout_ptr/shared_ptr_neg.cc:
	New test.
	* testsuite/20_util/smartptr.adapt/inout_ptr/void_ptr.cc: New
	test.
	* testsuite/20_util/smartptr.adapt/out_ptr/1.cc: New test.
	* testsuite/20_util/smartptr.adapt/out_ptr/2.cc: New test.
	* testsuite/20_util/smartptr.adapt/out_ptr/shared_ptr_neg.cc:
	New test.
	* testsuite/20_util/smartptr.adapt/out_ptr/void_ptr.cc: New
	test.
2023-11-16 08:10:26 +00:00
Paul M. Bendixen
c1eee808a9 libstdc++: Include cstdarg in freestanding
P1642 includes cstdarg in the full headers to include.
This commit includes it along with cstdalign and cstdbool that were
left out when updating in an earlier commit.

libstdc++/Changelog

	* include/Makefile.am: Move cstdarg, cstdalign and cstdbool to
	freestanding.
	* include/Makefile.in: Regenerate.

Signed-off-by: Paul M. Bendixen <paulbendixen@gmail.com>
2023-10-24 21:21:31 +01:00
Jonathan Wakely
b10dfbb54e libstdc++: Regenerate Makefile.in
libstdc++-v3/ChangeLog:

	* include/Makefile.in: Regenerate.
2023-08-17 13:12:39 +01:00
Arsen Arsenović
b7b801b2f5 libstdc++: Implement more maintainable <version> header
This commit replaces the ad-hoc logic in <version> with an AutoGen
database that (mostly) declaratively generates a version.h bit which
combines all of the FTM logic across all headers together.

This generated header defines macros of the form __glibcxx_foo,
equivalent to their __cpp_lib_foo variants, according to rules specified
in version.def and, optionally, if __glibcxx_want_foo or
__glibcxx_want_all are defined, also defines __cpp_lib_foo forms with
the same definition.

libstdc++-v3/ChangeLog:

	* include/Makefile.am (bits_freestanding): Add version.h.
	(allcreated): Add version.h.
	(${bits_srcdir}/version.h): New rule.  Regenerates
	version.h out of version.{def,tpl}.
	* include/Makefile.in: Regenerate.
	* include/bits/version.def: New file.  Declares a list of
	all feature test macros, their values and their preconditions.
	* include/bits/version.tpl: New file.  Turns version.def
	into a sequence of #if blocks.
	* include/bits/version.h: New file.  Generated from
	version.def.
	* include/std/version: Replace with a __glibcxx_want_all define
	and bits/version.h include.
2023-08-16 15:16:25 +02:00
Jonathan Wakely
b85c77e19a libstdc++: Implement <experimental/synchronized_value> (P0290)
This was approved for the Concurrency TS v2 in Issaquah.

Although the TS is based on C++20, this enables the new header for C++17
as well. This will make it available to more users, and I hope that will
get more feedback on the feature.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/experimental/synchronized_value: New file.
	* testsuite/experimental/synchronized_value.cc: New test.
2023-02-16 14:38:38 +00:00
Arsen Arsenović
42d3f74323 libstdc++: Enable string_view in freestanding
This enables the default contract handler in freestanding environments,
and, of course, provides freestanding users with string_view.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Install bits/char_traits.h,
	std/string_view
	* include/Makefile.in: Regenerate.
	* include/bits/char_traits.h: Gate hosted-only, wchar-only and
	mbstate-only bits behind appropriate #ifs.
	* include/std/string_view: Gate <iostream> functionality behind
	HOSTED.
	* include/std/version: Enable __cpp_lib_constexpr_string_view
	and __cpp_lib_starts_ends_with in !HOSTED.
	* include/std/ranges: Re-enable __is_basic_string_view on
	freestanding, include <string_view> directly.
	* include/precompiled/stdc++.h: Include <string_view> when
	!HOSTED too.
	* testsuite/20_util/function_objects/searchers.cc: Skip testing
	boyer_moore searchers on freestanding
	* testsuite/21_strings/basic_string_view/capacity/1.cc: Guard
	<string>-related tests behind __STDC_HOSTED__.
	* testsuite/21_strings/basic_string_view/cons/char/1.cc: Ditto.
	* testsuite/21_strings/basic_string_view/cons/char/2.cc: Remove
	unused <stdexcept> include.
	* testsuite/21_strings/basic_string_view/cons/char/3.cc: Remove
	unused <vector> include.
	* testsuite/21_strings/basic_string_view/cons/char/range.cc:
	Guard <string> related testing behind __STDC_HOSTED__.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/1.cc:
	Guard <stdexcept> related tests behind __STDC_HOSTED__.
	* testsuite/21_strings/basic_string_view/element_access/char/1.cc:
	Ditto.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/1.cc:
	Guard <stdexcept> tests behind __STDC_HOSTED__.
	* testsuite/21_strings/basic_string_view/operations/contains/char/2.cc:
	Enable test on freestanding, guard <stdexcept> bits behind
	__STDC_HOSTED__.
	* testsuite/21_strings/basic_string_view/operations/substr/char.cc:
	Guard <stdexcept> bits behind __STDC_HOSTED__.
	* testsuite/21_strings/basic_string_view/operations/substr/wchar_t.cc:
	Ditto.
2023-01-13 13:34:21 +00:00
Jonathan Wakely
f99b94865f libstdc++: Add std::format support to <chrono>
This adds the operator<< overloads and std::formatter specializations
required by C++20 so that <chrono> types can be written to ostreams and
printed with std::format.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/std/chrono (operator<<): Move to new header.
	(nonexistent_local_time::_M_make_what_str): Define correctly.
	(ambiguous_local_time::_M_make_what_str): Likewise.
	* include/bits/chrono_io.h: New file.
	* src/c++20/tzdb.cc (operator<<(ostream&, const Rule&)): Use
	new ostream output for month and weekday types.
	* testsuite/20_util/duration/io.cc: Test std::format support.
	* testsuite/std/time/exceptions.cc: Check what() strings.
	* testsuite/std/time/syn_c++20.cc: Uncomment local_time_format.
	* testsuite/std/time/time_zone/get_info_local.cc: Enable check
	for formatted output of local_info objects.
	* testsuite/std/time/clock/file/io.cc: New test.
	* testsuite/std/time/clock/gps/io.cc: New test.
	* testsuite/std/time/clock/system/io.cc: New test.
	* testsuite/std/time/clock/tai/io.cc: New test.
	* testsuite/std/time/clock/utc/io.cc: New test.
	* testsuite/std/time/day/io.cc: New test.
	* testsuite/std/time/format.cc: New test.
	* testsuite/std/time/hh_mm_ss/io.cc: New test.
	* testsuite/std/time/month/io.cc: New test.
	* testsuite/std/time/weekday/io.cc: New test.
	* testsuite/std/time/year/io.cc: New test.
	* testsuite/std/time/year_month_day/io.cc: New test.
2022-12-22 23:34:27 +00:00
Jeff Chapman II
ea63396f6b libstdc++: add experimental Contracts support
This patch adds the library support for the experimental C++ Contracts
implementation.  This now consists only of a default definition of the
violation handler, which users can override through defining their own
version.  To avoid ABI stability problems with libstdc++.so this is added to
a separate -lstdc++exp static library, which the driver knows to add when it
sees -fcontracts.

Co-authored-by: Andrew Marmaduke <amarmaduke@lock3software.com>
Co-authored-by: Jason Merrill  <jason@redhat.com>

libstdc++-v3/ChangeLog:

	* acinclude.m4 (glibcxx_SUBDIRS): Add src/experimental.
	* include/Makefile.am (experimental_headers): Add contract.
	* include/Makefile.in: Regenerate.
	* src/Makefile.am (SUBDIRS): Add experimental.
	* src/Makefile.in: Regenerate.
	* configure: Regenerate.
	* src/experimental/contract.cc: New file.
	* src/experimental/Makefile.am: New file.
	* src/experimental/Makefile.in: New file.
	* include/experimental/contract: New file.
2022-11-18 21:40:29 -05:00
Jonathan Wakely
1d9454aba6 libstdc++: Implement C++20 <format> [PR104166]
This doesn't add the newer C++23 features like formatting ranges
and escaped string prsentation types.

However, C++23 extended floating-point types are supported, as are
128-bit integers.

It could do with more tests.

libstdc++-v3/ChangeLog:

	PR libstdc++/104166
	* include/Makefile.am (std_headers): Add <format>.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Add <format>.
	* include/std/format: New file.
	* python/libstdcxx/v6/printers.py (StdFormatArgsPrinter): New
	printer for std::format_args.
	* testsuite/std/format/arguments/args.cc: New test.
	* testsuite/std/format/error.cc: New test.
	* testsuite/std/format/formatter.cc: New test.
	* testsuite/std/format/functions/format.cc: New test.
	* testsuite/std/format/functions/format_to_n.cc: New test.
	* testsuite/std/format/functions/size.cc: New test.
	* testsuite/std/format/functions/vformat_to.cc: New test.
	* testsuite/std/format/parse_ctx.cc: New test.
	* testsuite/std/format/string.cc: New test.
	* testsuite/std/format/string_neg.cc: New test.
2022-11-13 01:10:44 +00:00
Arsen Arsenović
655271e47f libstdc++: Don't use gstdint.h anymore
libstdc++-v3/ChangeLog:

	* configure.ac: Stop generating gstdint.h.
	* src/c++11/compatibility-atomic-c++0x.cc: Stop using gstdint.h.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* 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++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2022-10-29 00:55:42 +01:00
Jakub Jelinek
a23225fb4f libstdc++: Partial library support for std::float{16,32,64,128}_t and std::bfloat16_t
The following patch is partial support for std::float{16,32,64,128}_t
and std::bfloat16_t in libstdc++.
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html
says that <ostream>, <istream>, <charconv> and <complex>
need changes toom, but that isn't implemented so far.
In <cmath> the only thing missing I'm aware of is
std::nextafter std::float16_t and std::bfloat16_t overloads (I think
we probably need to implement that out of line somewhere, or inline? - might
need inline asm barriers) and std::nexttoward overloads (those are
intentional, you said there is a LWG issue about that).
Also, this patch has the glibc 2.26+ std::float128_t support for platforms
where long double isn't IEEE quad format temporarily disabled
because it depends on
https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603665.html
changes which aren't in yet.

The patch also doesn't include any testcases to cover the <type_traits>
changes, it isn't clear to me where to put that.

2022-10-18  Jakub Jelinek  <jakub@redhat.com>

	PR c++/106652
	* include/std/stdfloat: New file.
	* include/std/numbers (__glibcxx_numbers): Define and use it
	for __float128 explicit instantiations as well as
	_Float{16,32,64,128} and __gnu_cxx::__bfloat16_t.
	* include/std/atomic (atomic<_Float16>, atomic<_Float32>,
	atomic<_Float64>, atomic<_Float128>, atomic<__gnu_cxx::__bfloat16_t>):
	New explicit instantiations.
	* include/std/type_traits (__is_floating_point_helper<_Float16>,
	__is_floating_point_helper<_Float32>,
	__is_floating_point_helper<_Float64>,
	__is_floating_point_helper<_Float128>,
	__is_floating_point_helper<__gnu_cxx::__bfloat16_t>): Likewise.
	* include/std/limits (__glibcxx_concat3_, __glibcxx_concat3,
	__glibcxx_float_n): Define.
	(numeric_limits<_Float16>, numeric_limits<_Float32>,
	numeric_limits<_Float64>, numeric_limits<_Float128>,
	numeric_limits<__gnu_cxx::__bfloat16_t>): New explicit instantiations.
	* include/bits/std_abs.h (abs): New overloads for
	_Float{16,32,64,128} and __gnu_cxx::__bfloat16_t.
	* include/bits/c++config (_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128): Define
	if long double is IEEE quad.
	(__gnu_cxx::__bfloat16_t): New using.
	* include/c_global/cmath (acos, asin, atan, atan2, ceil, cos, cosh,
	exp, fabs, floor, fmod, frexp, ldexp, log, log10, modf, pow, sin,
	sinh, sqrt, tan, tanh, fpclassify, isfinite, isinf, isnan, isnormal,
	signbit, isgreater, isgreaterequal, isless, islessequal,
	islessgreater, isunordered, acosh, asinh, atanh, cbrt, copysign, erf,
	erfc, exp2, expm1, fdim, fma, fmax, fmin, hypot, ilogb, lgamma,
	llrint, llround, log1p, log2, logb, lrint, lround, nearbyint,
	nextafter, remainder, rint, round, scalbln, scalbn, tgamma, trunc,
	lerp): New overloads with _Float{16,32,64,128} or
	__gnu_cxx::__bfloat16_t types.
	* config/os/gnu-linux/os_defines.h (_GLIBCXX_HAVE_FLOAT128_MATH):
	Prepare for definition if glibc 2.26 and later implements *f128 APIs
	but comment out the actual definition for now.
	* include/ext/type_traits.h (__promote<_Float16>, __promote<_Float32>,
	__promote<_Float64>, __promote<_Float128>,
	__promote<__gnu_cxx::__bfloat16_t>): New specializations.
	* include/Makefile.am (std_headers): Add stdfloat.
	* include/Makefile.in: Regenerated.
	* include/precompiled/stdc++.h: Include stdfloat.
	* testsuite/18_support/headers/stdfloat/types_std.cc: New test.
	* testsuite/18_support/headers/limits/synopsis_cxx23.cc: New test.
	* testsuite/26_numerics/headers/cmath/c99_classification_macros_c++23.cc:
	New test.
	* testsuite/26_numerics/headers/cmath/functions_std_c++23.cc: New test.
	* testsuite/26_numerics/numbers/4.cc: New test.
	* testsuite/29_atomics/atomic_float/requirements_cxx23.cc: New test.
2022-10-18 11:37:13 +02:00
Jonathan Wakely
637e3668fd libstdc++: Allow emergency EH alloc pool size to be tuned [PR68606]
Implement a long-standing request to support tuning the size of the
emergency buffer for allocating exceptions after malloc fails, or to
disable that buffer entirely.

It's now possible to disable the dynamic allocation of the buffer and
use a fixed-size static buffer, via --enable-libstdcxx-static-eh-pool.
This is a built-time choice that is baked into libstdc++ and so affects
all code linked against that build of libstdc++.

The size of the pool can be set by --with-libstdcxx-eh-pool-obj-count=N
which is measured in units of sizeof(void*) not bytes. A given exception
type such as std::system_error depends on the target, so giving a size
in bytes wouldn't be portable across 16/32/64-bit targets.

When libstdc++ is configured to use a dynamic buffer, the size of that
buffer can now be tuned at runtime by setting the GLIBCXX_TUNABLES
environment variable (c.f. PR libstdc++/88264). The number of exceptions
to reserve space for is controlled by the "glibcxx.eh_pool.obj_count"
and "glibcxx.eh_pool.obj_size" tunables. The pool will be sized to be
able to allocate obj_count exceptions of size obj_size*sizeof(void*) and
obj_count "dependent" exceptions rethrown by std::rethrow_exception.

With the ability to tune the buffer size, we can reduce the default pool
size on 32-bit and 16-bit targets. Most users never need to throw 1kB
exceptions in parallel from hundreds of threads after malloc is OOM. The
users who do need that can use the tunables to select larger sizes.

The old defaults can be chosen at runtime by setting GLIBCXX_TUNABLES
to:
64-bit: glibcxx.eh_pool.obj_count=64:glibcxx.eh_pool.obj_size=112
32-bit: glibcxx.eh_pool.obj_count=32:glibcxx.eh_pool.obj_size=104

Or approximated by configuring with:
64-bit: --with-libstdcxx-eh-pool-obj-count=252
32-bit: --with-libstdcxx-eh-pool-obj-count=94

libstdc++-v3/ChangeLog:

	PR libstdc++/68606
	* Makefile.in: Regenerate.
	* acinclude.m4 (GLIBCXX_EMERGENCY_EH_ALLOC): New macro.
	* configure: Regenerate.
	* configure.ac: Use GLIBCXX_EMERGENCY_EH_ALLOC.
	* crossconfig.m4: Check for secure_getenv.
	* doc/Makefile.in: Regenerate.
	* doc/xml/manual/configure.xml: Document new configure options.
	* doc/xml/manual/evolution.xml: Document addition of tunables.
	* doc/xml/manual/using_exceptions.xml: Document emergency
	buffer and tunables.
	* doc/html/*: Regenerate.
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.am: Use EH_POOL_FLAGS.
	* libsupc++/Makefile.in: Regenerate.
	* libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define in units
	of sizeof(void*) not including the ABI's exception header.
	(EMERGENCY_OBJ_COUNT): Define as target-independent calculation
	based on word size.
	(MAX_OBJ_COUNT): Define macro for upper limit on pool size.
	(pool) [_GLIBCXX_EH_POOL_STATIC]: Use fixed-size buffer.
	(pool::buffer_size_in_bytes): New static member function.
	(pool::pool): Parse GLIBCXX_TUNABLES environment variable to set
	pool size at runtime.
	(pool::in_pool): Use std::less<void*> for total order.
	(__freeres) [_GLIBCXX_EH_POOL_STATIC]: Do nothing.
	(__cxa_free_exception, __cxa_free_dependent_exception): Add
	[[unlikely]] attributes.
	* 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++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2022-10-11 16:21:48 +01:00
Jonathan Wakely
b8473c9a2b libtdc++: Regenerate Makefile.in after freestanding header changes
libstdc++-v3/ChangeLog:

	* include/Makefile.in: Regenerate.
2022-10-05 14:09:11 +01:00
Arsen Arsenović
6885e7e4ee libstdc++: Rework how freestanding install works [PR106953]
In light of there being far more freestanding headers now, ad-hoc
maintenance of a subset of the install implementation has become
unsustainable. Instead, we gate off a part of the normal install routine
so that it works without HOSTED enabled, as well as subdivide lists of
headers into freestanding and hosted components, according to the HOSTED
flag.

libstdc++-v3/ChangeLog:

	PR libstdc++/106953
	* include/Makefile.am [!_GLIBCXX_HOSTED]: Remove
	install-freestanding-headers, unifying it with the usual
	install-headers
	* include/Makefile.in: Regenerate.
2022-10-03 15:43:48 +01:00
Arsen Arsenović
18f176d0b2 libstdc++: Mark headers that must be hosted as such [PR103626]
PR libstdc++/103626 - _GLIBCXX_HOSTED should respect -ffreestanding

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

libstdc++-v3/ChangeLog:

	PR libstdc++/103626
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/requires_hosted.h: New header.
	* include/experimental/algorithm: Include
	<bits/requires_hosted.h>.
	* include/experimental/any: Likewise.
	* include/experimental/array: Likewise.
	* include/experimental/buffer: Likewise.
	* include/experimental/chrono: Likewise.
	* include/experimental/deque: Likewise.
	* include/experimental/executor: Likewise.
	* include/experimental/filesystem: Likewise.
	* include/experimental/forward_list: Likewise.
	* include/experimental/functional: Likewise.
	* include/experimental/internet: Likewise.
	* include/experimental/io_context: Likewise.
	* include/experimental/iterator: Likewise.
	* include/experimental/list: Likewise.
	* include/experimental/map: Likewise.
	* include/experimental/memory: Likewise.
	* include/experimental/memory_resource: Likewise.
	* include/experimental/net: Likewise.
	* include/experimental/netfwd: Likewise.
	* include/experimental/numeric: Likewise.
	* include/experimental/optional: Likewise.
	* include/experimental/propagate_const: Likewise.
	* include/experimental/random: Likewise.
	* include/experimental/ratio: Likewise.
	* include/experimental/regex: Likewise.
	* include/experimental/scope: Likewise.
	* include/experimental/set: Likewise.
	* include/experimental/simd: Likewise.
	* include/experimental/socket: Likewise.
	* include/experimental/source_location: Likewise.
	* include/experimental/string: Likewise.
	* include/experimental/string_view: Likewise.
	* include/experimental/system_error: Likewise.
	* include/experimental/timer: Likewise.
	* include/experimental/tuple: Likewise.
	* include/experimental/unordered_map: Likewise.
	* include/experimental/unordered_set: Likewise.
	* include/experimental/utility: Likewise.
	* include/experimental/vector: Likewise.
	* include/std/barrier: Likewise.
	* include/std/chrono: Likewise.
	* include/std/condition_variable: Likewise.
	* include/std/deque: Likewise.
	* include/std/execution: Likewise.
	* include/std/filesystem: Likewise.
	* include/std/forward_list: Likewise.
	* include/std/fstream: Likewise.
	* include/std/future: Likewise.
	* include/std/iomanip: Likewise.
	* include/std/ios: Likewise.
	* include/std/iosfwd: Likewise.
	* include/std/iostream: Likewise.
	* include/std/istream: Likewise.
	* include/std/latch: Likewise.
	* include/std/list: Likewise.
	* include/std/locale: Likewise.
	* include/std/map: Likewise.
	* include/std/memory_resource: Likewise.
	* include/std/mutex: Likewise.
	* include/std/ostream: Likewise.
	* include/std/queue: Likewise.
	* include/std/random: Likewise.
	* include/std/regex: Likewise.
	* include/std/semaphore: Likewise.
	* include/std/set: Likewise.
	* include/std/shared_mutex: Likewise.
	* include/std/spanstream: Likewise.
	* include/std/sstream: Likewise.
	* include/std/stack: Likewise.
	* include/std/stacktrace: Likewise.
	* include/std/stop_token: Likewise.
	* include/std/streambuf: Likewise.
	* include/std/string: Likewise.
	* include/std/syncstream: Likewise.
	* include/std/system_error: Likewise.
	* include/std/thread: Likewise.
	* include/std/unordered_map: Likewise.
	* include/std/unordered_set: Likewise.
	* include/std/valarray: Likewise.
	* include/std/vector: Likewise.
	* include/tr1/array: Likewise.
	* include/tr1/ccomplex: Likewise.
	* include/tr1/cctype: Likewise.
	* include/tr1/cfenv: Likewise.
	* include/tr1/cfloat: Likewise.
	* include/tr1/cinttypes: Likewise.
	* include/tr1/climits: Likewise.
	* include/tr1/cmath: Likewise.
	* include/tr1/complex: Likewise.
	* include/tr1/complex.h: Likewise.
	* include/tr1/cstdarg: Likewise.
	* include/tr1/cstdbool: Likewise.
	* include/tr1/cstdint: Likewise.
	* include/tr1/cstdio: Likewise.
	* include/tr1/cstdlib: Likewise.
	* include/tr1/ctgmath: Likewise.
	* include/tr1/ctime: Likewise.
	* include/tr1/ctype.h: Likewise.
	* include/tr1/cwchar: Likewise.
	* include/tr1/cwctype: Likewise.
	* include/tr1/fenv.h: Likewise.
	* include/tr1/float.h: Likewise.
	* include/tr1/functional: Likewise.
	* include/tr1/inttypes.h: Likewise.
	* include/tr1/limits.h: Likewise.
	* include/tr1/math.h: Likewise.
	* include/tr1/memory: Likewise.
	* include/tr1/random: Likewise.
	* include/tr1/regex: Likewise.
	* include/tr1/stdarg.h: Likewise.
	* include/tr1/stdbool.h: Likewise.
	* include/tr1/stdint.h: Likewise.
	* include/tr1/stdio.h: Likewise.
	* include/tr1/stdlib.h: Likewise.
	* include/tr1/tgmath.h: Likewise.
	* include/tr1/tuple: Likewise.
	* include/tr1/type_traits: Likewise.
	* include/tr1/unordered_map: Likewise.
	* include/tr1/unordered_set: Likewise.
	* include/tr1/utility: Likewise.
	* include/tr1/wchar.h: Likewise.
	* include/tr1/wctype.h: Likewise.
	* include/c_global/cmath: Likewise.
	* include/ext/algorithm: Include <bits/requires_hosted.h>.
	* include/ext/bitmap_allocator.h: Likewise.
	* include/ext/cmath: Likewise.
	* include/ext/codecvt_specializations.h: Likewise.
	* include/ext/debug_allocator.h: Likewise.
	* include/ext/enc_filebuf.h: Likewise.
	* include/ext/extptr_allocator.h: Likewise.
	* include/ext/functional: Likewise.
	* include/ext/malloc_allocator.h: Likewise.
	* include/ext/memory: Likewise.
	* include/ext/mt_allocator.h: Likewise.
	* include/ext/new_allocator.h: Likewise.
	* include/ext/numeric: Likewise.
	* include/ext/pod_char_traits.h: Likewise.
	* include/ext/pool_allocator.h: Likewise.
	* include/ext/random: Likewise.
	* include/ext/random.tcc: Likewise.
	* include/ext/rb_tree: Likewise.
	* include/ext/rc_string_base.h: Likewise.
	* include/ext/rope: Likewise.
	* include/ext/ropeimpl.h: Likewise.
	* include/ext/slist: Likewise.
	* include/ext/sso_string_base.h: Likewise.
	* include/ext/stdio_filebuf.h: Likewise.
	* include/ext/stdio_sync_filebuf.h: Likewise.
	* include/ext/string_conversions.h: Likewise.
	* include/ext/throw_allocator.h: Likewise.
	* include/ext/vstring.h: Likewise.
	* include/ext/vstring.tcc: Likewise.
	* include/ext/vstring_fwd.h: Likewise.
	* include/ext/vstring_util.h: Likewise.
	* include/std/charconv: Likewise.
	(__cpp_lib_to_chars): Do not define for freestanding.
	* include/std/version: Adjust which macros get defined in
	freestanding.
	* include/ext/pointer.h [!_GLIBCXX_HOSTED]: Omit iostream
	functionality from freestanding.
	* include/std/algorithm [!_GLIBCXX_HOSTED]: Omit PSTL algos.
	* include/std/memory [!_GLIBCXX_HOSTED]: Omit
	<bits/stl_tempbuf.h> in freestanding
	* include/bits/algorithmfwd.h [!_GLIBCXX_HOSTED]: Omit leftover
	random_shuffle and stable_partition definition.
	* include/bits/stl_algo.h [!_GLIBCXX_HOSTED]: Omit
	random_shuffle and stable_partition from freestanding.
	* include/bits/ranges_algo.h [!_GLIBCXX_HOSTED]: Omit
	stable_partition from freestanding.
	* include/bits/concept_check.h: Remove needless HOSTED check.
	* include/std/iterator: Include <bits/ranges_base.h>.
	* include/std/numeric (__cpp_lib_parallel_algorithms): Do not
	define for freestanding.
	* include/std/functional (__cpp_lib_boyer_moore_searcher):
	Likewise.
	* testsuite/lib/prune.exp: Match error for hosted-only libstdc++
	tests.
2022-10-03 15:43:48 +01:00
Jonathan Wakely
f1b51f68f8 libstdc++: Make _GLIBCXX_HOSTED respect -ffreestanding [PR103626]
This allows the library to switch to freestanding mode when compiling
with the -ffreestanding flag. This means you don't need a separate
libstdc++ build configured with --disable-hosted-libstdcxx in order to
compile for a freestanding environment.

The testsuite support files cannot be compiled for freestanding, so add
-fno-freestanding to override any -ffreestanding in the test flags.

libstdc++-v3/ChangeLog:

	PR libstdc++/103626
	* acinclude.m4 (GLIBCXX_ENABLE_HOSTED): Define _GLIBCXX_HOSTED
	to __STDC_HOSTED__ for non-freestanding installations.
	* configure: Regenerate.
	* include/Makefile.am (${host_builddir}/c++config.h): Adjust
	grep pattern.
	* include/Makefile.in: Regenerate.
	* testsuite/lib/libstdc++.exp (v3-build_support): Use
	-fno-freestanding.
	* testsuite/libstdc++-abi/abi.exp: Likewise.
2022-10-03 15:43:48 +01:00
Jonathan Wakely
29fc5075d7 libstdc++: Implement <experimental/scope> from LFTSv3
libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/experimental/scope: New file.
	* testsuite/experimental/scopeguard/uniqueres.cc: New test.
	* testsuite/experimental/scopeguard/exit.cc: New test.
2022-08-05 14:57:31 +01:00
Jonathan Wakely
8a6ee426c2 libstdc++: Add missing prerequisite to generated header [PR106162]
The ${host_builddir}/largefile-config.h header can't be written until
its parent directory has been created, so it needs to have the creation
of that directory as a prerequisite.

libstdc++-v3/ChangeLog:

	PR libstdc++/106162
	* include/Makefile.am (largefile-config.h): Add
	stamp-${host_alias} prerequisite.
	* include/Makefile.in: Regenerate.
2022-07-01 22:42:55 +01:00
Jonathan Wakely
8ccdc7ce33 libstdc++: Ensure pmr aliases work without <memory_resource>
Currently the alias templates for std::pmr::vector, std::pmr::string
etc. are defined using a forward declaration for polymorphic_allocator.
This means you can't actually use the alias templates unless you also
include <memory_resource>. The rationale for that is that it's a fairly
large header, and most users don't need it. This isn't uncontroversial
though, and LWG 3681 questions whether it's even conforming.

This change adds a new <bits/memory_resource.h> header with the minimum
needed to use polymorphic_allocator and the std::pmr container aliases.
Including <memory_resource> is still necessary to use the program-wide
resource objects, or the pool resources or monotonic buffer resource.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/memory_resource.h: New file.
	* include/std/deque: Include <bits/memory_resource.h>.
	* include/std/forward_list: Likewise.
	* include/std/list: Likewise.
	* include/std/map: Likewise.
	* include/std/memory_resource (pmr::memory_resource): Move to
	new <bits/memory_resource.h> header.
	(pmr::polymorphic_allocator): Likewise.
	* include/std/regex: Likewise.
	* include/std/set: Likewise.
	* include/std/stacktrace: Likewise.
	* include/std/string: Likewise.
	* include/std/unordered_map: Likewise.
	* include/std/unordered_set: Likewise.
	* include/std/vector: Likewise.
	* testsuite/21_strings/basic_string/types/pmr_typedefs.cc:
	Remove <memory_resource> header and check construction.
	* testsuite/23_containers/deque/types/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/forward_list/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/list/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/map/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/multimap/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/multiset/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/set/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/unordered_map/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/vector/pmr_typedefs.cc: Likewise.
	* testsuite/28_regex/match_results/pmr_typedefs.cc: Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/variadic-tuple.C: Qualify function to avoid ADL
	finding std::make_tuple.
2022-05-19 23:38:23 +01:00
Jonathan Wakely
b78e0ce28b libstdc++: Define std::expected for C++23 (P0323R12)
Because this adds a new class template called std::unexpected, we have
to stop declaring the std::unexpected() function (which was deprecated
in C++11 and removed in C++17).

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in: Add new header.
	* include/Makefile.am: Likewise.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Add new header.
	* include/std/version (__cpp_lib_expected): Define.
	* libsupc++/exception [__cplusplus > 202002] (unexpected)
	(unexpected_handler, set_unexpected): Do not declare for C++23.
	* include/std/expected: New file.
	* testsuite/20_util/expected/assign.cc: New test.
	* testsuite/20_util/expected/cons.cc: New test.
	* testsuite/20_util/expected/illformed_neg.cc: New test.
	* testsuite/20_util/expected/observers.cc: New test.
	* testsuite/20_util/expected/requirements.cc: New test.
	* testsuite/20_util/expected/swap.cc: New test.
	* testsuite/20_util/expected/synopsis.cc: New test.
	* testsuite/20_util/expected/unexpected.cc: New test.
	* testsuite/20_util/expected/version.cc: New test.
2022-03-27 18:50:31 +01:00