libstdc++-v3/ChangeLog:
PR libstdc++/105154
* include/std/expected (expected<void, E>::swap): Set
_M_has_value to false for objects that previously had a value.
* testsuite/20_util/expected/swap.cc: Fix test to check void
specialization.
Without this, for a target where alignment and structure-sizes are by
default byte-aligned, such as cris-elf, you'll see, in libstdc++.log:
/X/gcc/libstdc++-v3/testsuite/20_util/expected/requirements.cc:127: error: static assertion failed
/X/gcc/libstdc++-v3/testsuite/20_util/expected/requirements.cc:127: note: the comparison reduces to '(5 == 2)'
compiler exited with status 1
FAIL: 20_util/expected/requirements.cc (test for excess errors)
Excess errors:
/X/gcc/libstdc++-v3/testsuite/20_util/expected/requirements.cc:127: error: static assertion failed
The intent of that line is to check that the object is not larger than
necessary.
libstdc++-v3/:
* testsuite/20_util/expected/requirements.cc: Correct minimal-size
test.
This defines std::unreachable as an assertion for debug mode, a trap
when _GLIBCXX_ASSERTIONS is defined, and __builtin_unreachable()
otherwise.
The reason for only using __builtin_trap() in the second case is to
avoid the overhead of setting up a call to __glibcxx_assert_fail that
should never happen.
UBsan can detect if __builtin_unreachable() is executed, so if a feature
test macro for that sanitizer is added, we could change just use
__builtin_unreachable() when the sanitizer is enabled.
While thinking about what the debug assertion failure should print, I
noticed that the __glibcxx_assert_fail function doesn't check for null
pointers. This adds a check so we don't try to print them if null.
libstdc++-v3/ChangeLog:
* include/std/utility (unreachable): Define for C++23.
* include/std/version (__cpp_lib_unreachable): Define.
* src/c++11/debug.cc (__glibcxx_assert_fail): Check for valid
arguments. Handle only the function being given.
* testsuite/20_util/unreachable/1.cc: New test.
* testsuite/20_util/unreachable/version.cc: New test.
These tests depend on unexpected handlers, which are no longer declared
for C++23 mode. Adjust the target specifier so they don't run.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/noexcept06.C: Disable for C++23.
libstdc++-v3/ChangeLog:
* testsuite/18_support/exception/38732.cc: Disable for C++23.
* testsuite/18_support/headers/exception/synopsis.cc: Likewise.
* testsuite/18_support/unexpected_handler.cc: Likewise.
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.
Our std::bit_cast was relying on the compiler to check for errors inside
__builtin_bit_cast, instead of checking them as constraints. That means
std::bit_cast was not SFINAE-friendly.
This fix uses a requires-clause, so for old versions of Clang without
concepts support the function will still be unconstrained. At some point
in future we can remove the #ifdef __cpp_concepts check and rely on all
compilers having full concepts support in C++20 mode.
libstdc++-v3/ChangeLog:
PR libstdc++/105027
* include/std/bit (bit_cast): Add constraints.
* testsuite/26_numerics/bit/bit.cast/105027.cc: New test.
Without this, for a typical soft-float target such as cris-elf, after
commit r12-7676-g5a4e208022e704 you'll see, in libstdc++.log:
...
FAIL: 20_util/from_chars/6.cc (test for excess errors)
Excess errors:
/home/hp/tmp/auto0321/gcc/libstdc++-v3/testsuite/20_util/from_chars/6.cc:33: error: 'FE_DOWNWARD' was not declared in this scope
UNRESOLVED: 20_util/from_chars/6.cc compilation failed to produce executable
...
It appears to be a side-effect of that commit changing the
way __cpp_lib_to_chars is defined. (On the bright side,
./7.cc now passes since that commit.)
TFM, specifically fenv(3), says that "Each of the macros
FE_DIVBYZERO, FE_INEXACT, FE_INVALID, FE_OVERFLOW,
FE_UNDERFLOW is defined when the implementation supports
handling of the corresponding exception".
A git-grep shows that this was the only place using a FE_ macro
unconditionally.
libstdc++-v3:
* testsuite/20_util/from_chars/6.cc (test01) [FE_DOWNWARD]:
Conditionalize call to fesetround.
Partially revert r12-4190-g6da36b7d0e43b6f9281c65c19a025d4888a25b2d
because using __and_<..., is_copy_constructible<T>> when T is incomplete
results in an error about deriving from is_copy_constructible<T> when
that is incomplete. I don't know how to fix that, so this simply
restores the previous constraint which worked in this case (even though
I think it's technically undefined to use is_copy_constructible<T> with
incomplete T). This doesn't restore exactly what we had before, but uses
the is_copy_constructible_v and __is_in_place_type_v variable templates
instead of the ::value member.
libstdc++-v3/ChangeLog:
PR libstdc++/104242
* include/std/any (any(T&&)): Revert change to constraints.
* testsuite/20_util/any/cons/104242.cc: New test.
This avoids including the whole of <functional> in <algorithm>, as the
<pstl/glue_algorithm_defs.h> header only actually needs std::pair.
This also avoids including <iterator> in <pstl/utils.h>, which only
needs <type_traits>, std::bad_alloc, and std::terminate (which can be
repalced with std::__terminate). This matters less, because
<pstl/utils.h> is only included by the <pstl/*_impl.h> headers and they
all use <iterator> anyway, and are only included by <execution>.
libstdc++-v3/ChangeLog:
PR libstdc++/92546
* include/pstl/glue_algorithm_defs.h: Replace <functional> with
<bits/stl_pair.h>.
* include/pstl/utils.h: Replace <iterator> with <type_traits>.
(__pstl::__internal::__except_handler): Use std::__terminate
instead of std::terminate.
* src/c++17/fs_path.cc: Include <array>.
* testsuite/25_algorithms/adjacent_find/constexpr.cc: Include
<functional>.
* testsuite/25_algorithms/binary_search/constexpr.cc: Likewise.
* testsuite/25_algorithms/clamp/constrained.cc: Likewise.
* testsuite/25_algorithms/equal/constrained.cc: Likewise.
* testsuite/25_algorithms/for_each/constrained.cc: Likewise.
* testsuite/25_algorithms/includes/constrained.cc: Likewise.
* testsuite/25_algorithms/is_heap/constexpr.cc: Likewise.
* testsuite/25_algorithms/is_heap_until/constexpr.cc: Likewise.
* testsuite/25_algorithms/is_permutation/constrained.cc: Include
<iterator>.
* testsuite/25_algorithms/is_sorted/constexpr.cc: Include
<functional>.
* testsuite/25_algorithms/is_sorted_until/constexpr.cc:
Likewise.
* testsuite/25_algorithms/lexicographical_compare/constexpr.cc:
Likewise.
* testsuite/25_algorithms/lexicographical_compare/constrained.cc:
Likewise.
* testsuite/25_algorithms/lexicographical_compare_three_way/1.cc:
Include <array>.
* testsuite/25_algorithms/lower_bound/constexpr.cc: Include
<functional>.
* testsuite/25_algorithms/max/constrained.cc: Likewise.
* testsuite/25_algorithms/max_element/constrained.cc: Likewise.
* testsuite/25_algorithms/min/constrained.cc: Likewise.
* testsuite/25_algorithms/min_element/constrained.cc: Likewise.
* testsuite/25_algorithms/minmax_element/constrained.cc:
Likewise.
* testsuite/25_algorithms/mismatch/constexpr.cc: Likewise.
* testsuite/25_algorithms/move/93872.cc: Likewise.
* testsuite/25_algorithms/move_backward/93872.cc: Include
<iterator>.
* testsuite/25_algorithms/nth_element/constexpr.cc: Include
<functional>.
* testsuite/25_algorithms/partial_sort/constexpr.cc: Likewise.
* testsuite/25_algorithms/partial_sort_copy/constexpr.cc:
Likewise.
* testsuite/25_algorithms/search/constexpr.cc: Likewise.
* testsuite/25_algorithms/search_n/constrained.cc: Likewise.
* testsuite/25_algorithms/set_difference/constexpr.cc: Likewise.
* testsuite/25_algorithms/set_difference/constrained.cc:
Likewise.
* testsuite/25_algorithms/set_intersection/constexpr.cc:
Likewise.
* testsuite/25_algorithms/set_intersection/constrained.cc:
Likewise.
* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc:
Likewise.
* testsuite/25_algorithms/set_union/constexpr.cc: Likewise.
* testsuite/25_algorithms/set_union/constrained.cc: Likewise.
* testsuite/25_algorithms/sort/constexpr.cc: Likewise.
* testsuite/25_algorithms/sort_heap/constexpr.cc: Likewise.
* testsuite/25_algorithms/transform/constrained.cc: Likewise.
* testsuite/25_algorithms/unique/constexpr.cc: Likewise.
* testsuite/25_algorithms/unique/constrained.cc: Likewise.
* testsuite/25_algorithms/unique_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/upper_bound/constexpr.cc: Likewise.
* testsuite/std/ranges/adaptors/elements.cc: Include <vector>.
* testsuite/std/ranges/adaptors/lazy_split.cc: Likewise.
* testsuite/std/ranges/adaptors/split.cc: Likewise.
The new std::from_chars implementation means that those symbols are now
defined on Solaris 11.3, which lacks uselocale. They were not present in
gcc-11, but the linker script gives them the GLIBCXX_3.4.29 symbol
version because that is the version where they appeared for systems with
uselocale.
This makes the version for those symbols depend on whether uselocale is
available or not, so that they get version GLIBCXX_3.4.30 on targets
where they weren't defined in gcc-11.
In order to avoid needing separate ABI baseline files for Solaris 11.3
and 11.4, the ABI checker program now treats the floating-point
std::from_chars overloads as undesignated if they are not found in the
baseline symbols file. This means they can be left out of the SOlaris
baseline without causing the check-abi target to fail.
libstdc++-v3/ChangeLog:
PR libstdc++/103407
* config/abi/pre/gnu.ver: Make version for std::from_chars
depend on HAVE_USELOCALE macro.
* testsuite/util/testsuite_abi.cc (compare_symbols): Treat
std::from_chars for floating-point types as undesignated if
not found in the baseline symbols file.
The std::__debug::vector isn't usable in constant expressions, so this
test fails in debug mode. Until the debug vector is fixed we can just
make the test use the non-debug one.
libstdc++-v3/ChangeLog:
PR libstdc++/104748
* testsuite/std/ranges/adaptors/all.cc: Use non-debug vector for
constexpr test.
This fixes a test failure due to a non-reserved name in an AIX system
header (included via <pthread.h>). That name clashes with one of the
names we check our own headers for, so skip checking that name on AIX.
libstdc++-v3/ChangeLog:
* testsuite/17_intro/names.cc (func): Undef on AIX.
This removes a FIXME in <compare>, defining the total order for
floating-point types. I originally opened PR96526 to request a new
compiler built-in to implement this, but now that we have std::bit_cast
it can be done entirely in the library.
The implementation is based on the glibc definitions of totalorder,
totalorderf, totalorderl etc.
I think this works for all the types that satisfy std::floating_point
today, and should also work for the types expected to be added by P1467
except for std::bfloat16_t. It also supports some additional types that
don't currently satisfy std::floating_point, such as __float80, but we
probably do want that to satisfy the concept for non-strict modes.
libstdc++-v3/ChangeLog:
PR libstdc++/96526
* libsupc++/compare (strong_order): Add missing support for
floating-point types.
* testsuite/18_support/comparisons/algorithms/strong_order_floats.cc:
New test.
This implements the wording changes in P2415R2 "What is a view?", which
is a DR for C++20.
libstdc++-v3/ChangeLog:
* include/bits/ranges_base.h (__detail::__is_initializer_list):
Define.
(viewable_range): Adjust as per P2415R2.
* include/bits/ranges_cmp.h (__cpp_lib_ranges): Adjust value.
* include/std/ranges (owning_view): Define as per P2415R2.
(enable_borrowed_range<owning_view>): Likewise.
(views::__detail::__can_subrange): Replace with ...
(views::__detail::__can_owning_view): ... this.
(views::_All::_S_noexcept): Sync with operator().
(views::_All::operator()): Use owning_view instead of subrange
as per P2415R2.
* include/std/version (__cpp_lib_ranges): Adjust value.
* testsuite/std/ranges/adaptors/all.cc (test06): Adjust now that
views::all uses owning_view instead of subrange.
(test08): New test.
* testsuite/std/ranges/adaptors/lazy_split.cc (test09): Adjust
now that rvalue non-view non-borrowed ranges are viewable.
* testsuite/std/ranges/adaptors/split.cc (test06): Likewise.
The SGI STL and pre-1998 drafts of the C++ standard had a default
argument for vector<bool>::insert(iterator, const bool&) which was
remove by N1051. The default argument is still present in libstdc++ for
some reason. There are no tests verifying it as an extension, so I don't
think it has been kept intentionally.
This removes the default argument but adds an overload without the
second parameter, and adds the deprecated attribute to it. This allows
any code using it to keep working (for now) but with a warning.
libstdc++-v3/ChangeLog:
PR libstdc++/104559
* doc/xml/manual/evolution.xml: Document deprecation.
* doc/html/manual/api.html: Regenerate.
* include/bits/stl_bvector.h (insert(const_iterator, const bool&)):
Remove default argument.
(insert(const_iterator)): New overload with deprecated attribute.
* testsuite/23_containers/vector/bool/modifiers/insert/104559.cc:
New test.
This attempts to implement a partial workaround for the GDB bug
https://sourceware.org/bugzilla/show_bug.cgi?id=28856 which causes GDB
to crash when printing a frame with a std::error_code argument.
By recognising the known error categories defined in the library and
hardcoding their names we do not need to call cat->name() on the
category. This has the additional benefit of also working when
debugging a core file rather than a running process. For those known
categories we can also cast the int value to the corresponding error
code enum (e.g. future_errc) so that we show an enumerator instead of
just an integer.
For program-defined categories we just use the name of the dynamic type
to identify the category, and print the value as an integer. Once the
GDB bug is fixed and the virtual name() function can be called safely,
that would be preferable. For now it's better to have an imperfect
printer that doesn't crash GDB.
This rewritten StdErrorCodePrinter needs gdb.Value.dynamic_type, so is
only registered if that is supported, which means GDB 7.7 and later.
libstdc++-v3/ChangeLog:
* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Replace
code that call cat->name() on std::error_category objects.
Identify known categories by symbol name and use a hardcoded
name. Print error code values as enumerators where appopriate.
* testsuite/libstdc++-prettyprinters/cxx11.cc: Adjust expected
name of custom category. Check io_errc and future_errc errors.
The std::__convert_from_v helper that formats double and long double
values into a char buffer was not being duplicated for the two long
double ABIs. This resulted in an ODR violation inside the library, where
some callers needed it to use snprintf to format __ibm128 values and
other callers needed it to use __snprintfieee128 to format __ieee128
values. The linker discarded one of the definitions, leaving one set of
callers using the wrong code.
This puts __convert_from_v in the __gnu_cxx_ieee128 inline namespace
when long double is __ieee128, so that there are two different
definitions of the function.
The std::money_put::__do_put overload for __ibm128 values needs a
different fix, because that is defined when long double is __ieee128 and
so would call the one in the inline namespace. That can be fixed by just
inlining the code directly into the function and using an asm alias to
call the right version of snprintf for the __ibm128 format. The code to
do that can be simpler than __convert_from_v because if we're defining
the ALT128_COMPAT symbols we know that we have a recent glibc and so we
can assume that uselocale and snprintf are supported.
libstdc++-v3/ChangeLog:
PR libstdc++/100912
* config/locale/gnu/c_locale.h (__convert_from_v): Use inline
namespace for IEEE128 long double mode.
* config/os/gnu-linux/ldbl-ieee128-extra.ver: Add new symbol
version and export __gnu_cxx_ieee128::__convert_from_v.
* include/bits/locale_facets_nonio.tcc (money_put::__do_put):
Make __ibm128 overload use snprintf directly
* testsuite/util/testsuite_abi.cc: Add new symbol version.
Remove stable IEEE128/LDBL versions.
The std::get_temporary_buffer function is deprecated since C++17, but
the test was expecting a warning for C++14 as well.
libstdc++-v3/ChangeLog:
* testsuite/20_util/temporary_buffer.cc: Fix dg-warning target
selector.
This function (and the explicit memory over version) are present in both
C++ <atomic> and C <stdatomic.h>, so should be in C++ <stdatomic.h> too.
There is a library issue incoming for this, but the resolution is
obvious.
libstdc++-v3/ChangeLog:
* include/c_compatibility/stdatomic.h (atomic_fetch_xor): Add
using-declaration.
(atomic_fetch_xor_explicit): Likewise.
* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc: Check
arithmetic and logical operations for atomic_int.
The Filesystem TS isn't really supported for Windows, but the FAIL for
this test is just because it doesn't match what happens on Windows.
libstdc++-v3/ChangeLog:
* testsuite/experimental/filesystem/operations/create_directories.cc:
Adjust expected results for Windows.
These tests instantiate std::multiset and std::set with a type that has
no operator< so they should use a custom comparison function.
libstdc++-v3/ChangeLog:
* testsuite/23_containers/multiset/operators/cmp_c++20.cc: Use
custom comparison function for multiset.
* testsuite/23_containers/set/operators/cmp_c++20.cc: Use custom
comparison function for set.
These new tests should not use the d_type member unless it's actually
present on the OS.
libstdc++-v3/ChangeLog:
* testsuite/27_io/filesystem/iterators/error_reporting.cc: Use
autoconf macro to check whether d_type is present.
* testsuite/experimental/filesystem/iterators/error_reporting.cc:
Likewise.
The PR 97731 test was added to verify a fix to the Filesystem TS code,
but we should also have the same test to avoid similar regressions in
the C++17 std::filesystem code.
Also add tests for directory_options::follow_directory_symlink
libstdc++-v3/ChangeLog:
* testsuite/27_io/filesystem/iterators/97731.cc: New test.
* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc:
Check follow_directory_symlink option.
* testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc:
Likewise.
The standard requires directory iterators to become equal to the end
iterator value if they report an error. Some members functions of
filesystem::recursive_directory_iterator fail to do that.
libstdc++-v3/ChangeLog:
* src/c++17/fs_dir.cc (recursive_directory_iterator::increment):
Reset state to past-the-end iterator on error.
(fs::recursive_directory_iterator::pop(error_code&)): Likewise.
(fs::recursive_directory_iterator::pop()): Check _M_dirs before
it might get reset.
* src/filesystem/dir.cc (recursive_directory_iterator): Likewise,
for the TS implementation.
* testsuite/27_io/filesystem/iterators/error_reporting.cc: New test.
* testsuite/experimental/filesystem/iterators/error_reporting.cc: New test.
These tests have always been failing for my autotester running a
cris-elf simulator; when unrestrained they take about 20 minutes each,
compared to the (doubled) timeout of 720 seconds, of a total 2h40min
for the whole of the libstdc++-v3 testsuite. The tests cover counter
overflow and are already disabled for LP64 targets.
* testsuite/27_io/basic_istream/get/char/lwg3464.cc: Don't run on
simulator targets.
* testsuite/27_io/basic_istream/get/wchar_t/lwg3464.cc: Likewise.
The compiler warns about the loop in deque::_M_range_initialize because
it doesn't know that the number of nodes has already been correctly
sized to match the size of the input. Use __builtin_unreachable to tell
it that the loop will never be entered if the number of elements is
smaller than a single node.
libstdc++-v3/ChangeLog:
PR libstdc++/100516
* include/bits/deque.tcc (_M_range_initialize<ForwardIterator>):
Add __builtin_unreachable to loop.
* testsuite/23_containers/deque/100516.cc: New test.
When (bound - i) or n is the most negative value of its type, the
negative of the value will overflow. Instead of abs(n) >= abs(bound - i)
use n >= (bound - i) when positive and n <= (bound - i) when negative.
The function has a precondition that they must have the same sign, so
this works correctly. The precondition check can be moved into the else
branch, and simplified.
The standard requires calling ranges::advance(i, bound) even if i==bound
is already true, which is technically observable, but that's pointless.
We can just return n in that case. Similarly, for i!=bound but n==0 we
are supposed to call ranges::advance(i, n), but that's pointless. An LWG
issue to allow omitting the pointless calls is expected to be filed.
libstdc++-v3/ChangeLog:
* include/bits/ranges_base.h (ranges::advance): Avoid signed
overflow. Do nothing if already equal to desired result.
* testsuite/24_iterators/range_operations/advance_overflow.cc:
New test.
libstdc++-v3/ChangeLog:
PR libstdc++/104032
* include/std/spanstream (basic_spanbuf(basic_spanbuf&&)): Use
mem-initializer for _M_buf.
(basic_spanbuf::Operator=(basic_spanbuf&&)): Fix ill-formed
member access.
* testsuite/27_io/spanstream/2.cc: New test.
I broke this unintentionally in r12-4259.
libstdc++-v3/ChangeLog:
PR libstdc++/104174
* include/bits/hashtable_policy.h (_Map_base): Add partial
specialization for maps with const key types.
* testsuite/23_containers/unordered_map/104174.cc: New test.
The new deleted constructors added by P2166R1 are a breaking change,
making previously valid code ill-formed in C++23. As a result, they
should only be defined for C++23 and not for C++11 and up.
libstdc++-v3/ChangeLog:
PR libstdc++/104099
* include/bits/basic_string.h (basic_string(nullptr_t)): Only
define for C++23.
(operator=(nullptr_t)): Likewise.
* include/bits/cow_string.h: Likewise.
* include/std/string_view (basic_string_view(nullptr_t)):
Likewise.
* testsuite/21_strings/basic_string/cons/char/nullptr.cc: Adjust
expected error. Add examples that become ill-formed in C++23.
* testsuite/21_strings/basic_string_view/cons/char/nonnull.cc:
Adjust expected errors.
* testsuite/21_strings/basic_string_view/cons/wchar_t/nonnull.cc:
Likewise.
The deprecated non-standard std::pair constructors that allow
constructing std::pair<move-only-type, pointer-type> from an rvalue and
a literal zero where not sufficiently constrained. They were viable when
constructing std::pair<copyable-type, pointer-type>, and that case
should work fine using the standard constructors.
Replace the constraints on the non-standard constructors so they are
only viable in cases that should actually be ill-formed according to the
standard.
Also rename __null_ptr_constant to __zero_as_null_pointer_constant so it
matches the name of the -Wzero-as-null-pointer-constant warning. Also
make the text of the deprecated warning describe the problem in more
detail.
libstdc++-v3/ChangeLog:
PR libstdc++/101124
* include/bits/stl_pair.h (pair): Adjust constraints on
deprecated constructors accepting literal zero as null pointer
constant. Improve wording of deprecated attribute.
* testsuite/20_util/pair/cons/99957.cc: Check that deprecated
constructors do not cause ambiguities for copyable types.
This patch completes implementation of the C++20 proposal P0482R6 [1] by
adding declarations of std::c8rtomb() and std::mbrtoc8() in <cuchar> if
provided by the C library in <uchar.h>.
This patch addresses feedback provided in response to a previous patch
submission [2].
Autoconf changes determine if the C library declares c8rtomb and mbrtoc8
at global scope when uchar.h is included and compiled with either
-fchar8_t or -std=c++20. New _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_FCHAR8_T
and _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20 configuration macros
reflect the probe results. The <cuchar> header declares these functions
in the std namespace only if available and the _GLIBCXX_USE_CHAR8_T
configuration macro is defined (by default it is defined if the C++20
__cpp_char8_t feature test macro is defined)
Patches to glibc to implement c8rtomb and mbrtoc8 have been submitted [3].
New tests validate the presence of these declarations. The tests pass
trivially if the C library does not provide these functions. Otherwise
they ensure that the functions are declared when <cuchar> is included
and either -fchar8_t or -std=c++20 is enabled.
1]: WG21 P0482R6
"char8_t: A type for UTF-8 characters and strings (Revision 6)"
https://wg21.link/p0482r6
[2]: [PATCH] C++ P0482R6 char8_t: declare std::c8rtomb and std::mbrtoc8
if provided by the C library
https://gcc.gnu.org/pipermail/libstdc++/2021-June/052685.html
[3]: "C++20 P0482R6 and C2X N2653"
[Patch 0/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135061.html
[Patch 1/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135062.html
[Patch 2/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135063.html
[Patch 3/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135064.html
libstdc++-v3/ChangeLog:
* acinclude.m4: Define config macros if uchar.h provides
c8rtomb() and mbrtoc8().
* config.h.in: Regenerate.
* configure: Regenerate.
* include/c_compatibility/uchar.h (c8rtomb, mbrtoc8): Define.
* include/c_global/cuchar (c8rtomb, mbrtoc8): Likewise.
* include/c_std/cuchar (c8rtomb, mbrtoc8): Likewise.
* testsuite/21_strings/headers/cuchar/functions_std_cxx20.cc:
New test.
* testsuite/21_strings/headers/cuchar/functions_std_fchar8_t.cc:
New test.
This adds the C++23 <stdatomic.h> header, as proposed by P0943R6, for
compatibility with C code.
There are still some ABI differences between atomic_xxx in C and C++
std::atomic_xxx in C++, so this only provides source compatibility, not
binary compatibility.
libstdc++-v3/ChangeLog:
* include/Makefile.am: Install new header.
* include/Makefile.in: Regenerate.
* include/c_compatibility/stdatomic.h: New file.
* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc: New test.
libstdc++-v3/ChangeLog:
* src/c++17/floating_from_chars.cc: Include <bit>.
(ascii_to_hexit, starts_with_ci): Conditionally define.
(__floating_from_chars_hex): Conditionally define.
(from_chars): Use __floating_from_chars_hex for
chars_format::hex parsing of binary32/64 float/double.
(testsuite/20_util/from_chars/7.cc): New test.
Add the <stacktrace> header and a new libstdc++_libbacktrace.a library
that provides the implementation. For now, the new library is only built
if --enable-libstdcxx-backtrace=yes is used. As with the Filesystem TS,
the new library is only provided as a static archive.
libstdc++-v3/ChangeLog:
* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): New macro.
* configure.ac: Use GLIBCXX_ENABLE_BACKTRACE.
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/std/stacktrace: New header.
* include/std/version (__cpp_lib_stacktrace): Define.
* Makefile.in: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* doc/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* python/Makefile.in: Regenerate.
* src/Makefile.am: 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.
* testsuite/Makefile.in: Regenerate.
* src/libbacktrace/Makefile.am: New file.
* src/libbacktrace/Makefile.in: New file.
* src/libbacktrace/backtrace-rename.h: New file.
* src/libbacktrace/backtrace-supported.h.in: New file.
* src/libbacktrace/config.h.in: New file.
* testsuite/lib/libstdc++.exp (check_effective_target_stacktrace):
New proc.
* testsuite/20_util/stacktrace/entry.cc: New test.
* testsuite/20_util/stacktrace/synopsis.cc: New test.
* testsuite/20_util/stacktrace/version.cc: New test.
This adds another piece of C++20, the std::atomic specializations for
std::shared_ptr and std::weak_ptr.
The new _Sp_atomic type mimics the structure of shared_ptr<T> and
weak_ptr<T>, holding a T* pointer (the one returned by get() on a
shared_ptr/weak ptr) and a _Sp_counted_base<>* pointer to the
ref-counted control block. For _Sp_atomic the low bit of the control
block pointer is used as a lock bit, to ensure only one thread will
access the object at a time. The pointer is actually stored as a
uintptr_t to avoid accidental dereferences of the pointer when unlocked
(which would be a race) or when locked (which would dereference the
wrong pointer value due to the low bit being set). To get a raw pointer
to the control block, the lock must be acquired. Converting between a
_Sp_atomic and a shared_ptr or weak_ptr requires manually adjusting the
T* and _Sp_counted_base<>* members of the shared/weak ptr, instead of
going through the public API. This must be done carefully to ensure that
any change in the number of owners is reflected in a ref-count update.
Co-authored-by: Thomas Rodgers <trodgers@redhat.com>
Signed-off-by: Thomas Rodgers <trodgers@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/shared_ptr_atomic.h (__cpp_lib_atomic_shared_ptr):
New macro.
(_Sp_atomic): New class template.
(atomic<shared_ptr<T>>, atomic<weak_ptr<T>>): New partial
specializations.
* include/bits/shared_ptr_base.h (__shared_count, __weak_count)
(__shared_ptr, __weak_ptr): Declare _Sp_atomic as a friend.
* include/std/version (__cpp_lib_atomic_shared_ptr): New macro.
* testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc: New
test.
* testsuite/20_util/weak_ptr/atomic_weak_ptr.cc: New test.
The test fails on Fedora 33+ because nl_NL locale got thousands
separator defined. Use one of ar_SA, bg_BG, bs_BA, pt_PT
or plain C locale instead.
2022-01-14 Uroš Bizjak <ubizjak@gmail.com>
libstdc++-v3/ChangeLog:
* testsuite/22_locale/numpunct/members/char/3.cc:
Require pt_PT locale instead of nl_NL.
(test02): Use pt_PT locale instead of nl_NL.
There are a lot of things in the C++ standard library which were
deprecated in C++11, and more in C++17. Some of them were removed after
deprecation and are no longer present in the standard at all. We have
not removed these from libstdc++ because keeping them as non-standard
extensions is conforming, and avoids gratuitously breaking user code,
and in some cases we need to keep using them to avoid ABI changes. But
we should at least give a warning for using them. That has not been done
previously because of the library's own uses of them (e.g. the
std::iterator class template used as a base class).
This adds deprecated attributes to the relevant components, and then
goes through the whole library to add diagnostic pragmas where needed to
suppress warnings about our internal uses of them. The tests are updated
to either expect the additional warnings, or to suppress them where we
aren't interested in them.
libstdc++-v3/ChangeLog:
PR libstdc++/91260
PR libstdc++/91383
PR libstdc++/95065
* include/backward/binders.h (bind1st, bind2nd): Add deprecated
attribute.
* include/bits/refwrap.h (_Maybe_unary_or_binary_function):
Disable deprecated warnings for base classes.
(_Reference_wrapper_base): Likewise.
* include/bits/shared_ptr_base.h (_Sp_owner_less): Likewise.
* include/bits/stl_bvector.h (_Bit_iterator_base): Likewise.
* include/bits/stl_function.h (unary_function, binary_function):
Add deprecated attribute.
(unary_negate, not1, binary_negate, not2, ptr_fun)
(pointer_to_unary_function, pointer_to_binary_function)
(mem_fun_t, const_mem_fun_t, mem_fun_ref_t, const_mem_fun_ref_t)
(mem_fun1_t, const_mem_fun1_t, mem_fun_ref1_t)
(const_mem_fun1_ref_t, mem_fun, mem_fun_ref): Add deprecated
attributes.
* include/bits/stl_iterator.h: Disable deprecated warnings for
std::iterator base classes.
* include/bits/stl_iterator_base_types.h (iterator): Add
deprecated attribute.
* include/bits/stl_map.h (map::value_compare): Disable
deprecated warnings for base class.
* include/bits/stl_multimap.h (multimap::value_compare):
Likewise.
* include/bits/stl_raw_storage_iter.h (raw_storage_iterator):
Add deprecated attribute.
* include/bits/stl_tempbuf.h (get_temporary_buffer): Likewise.
* include/bits/stream_iterator.h: Disable deprecated warnings.
* include/bits/streambuf_iterator.h: Likewise.
* include/ext/bitmap_allocator.h: Remove unary_function base
classes.
* include/ext/functional: Disable deprecated warnings.
* include/ext/rope: Likewise.
* include/ext/throw_allocator.h: Likewise.
* include/std/type_traits (result_of): Add deprecated attribute.
* include/tr1/functional: Disable deprecated warnings.
* include/tr1/functional_hash.h: Likewise.
* testsuite/20_util/function_objects/binders/1.cc: Add
-Wno-disable-deprecations.
* testsuite/20_util/function_objects/binders/3113.cc: Likewise.
* testsuite/20_util/function_objects/constexpr.cc: Add
dg-warning.
* testsuite/20_util/raw_storage_iterator/base.cc: Likewise.
* testsuite/20_util/raw_storage_iterator/dr2127.cc: Likewise.
* testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc:
Likewise.
* testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/reference_wrapper/24803.cc:
Likewise.
* testsuite/20_util/reference_wrapper/typedefs.cc: Enable for
C++20 and check for absence of nested types.
* testsuite/20_util/shared_ptr/comparison/less.cc: Remove
std::binary_function base class.
* testsuite/20_util/temporary_buffer.cc: Add dg-warning.
* testsuite/21_strings/basic_string/cons/char/69092.cc: Remove
std::iterator base class.
* testsuite/24_iterators/back_insert_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/front_insert_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/insert_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/istream_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/istreambuf_iterator/92285.cc:
Likewise.
* testsuite/24_iterators/istreambuf_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/ostream_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/ostreambuf_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/24_iterators/reverse_iterator/requirements/base_classes.cc:
Likewise.
* testsuite/25_algorithms/copy/34595.cc:
Likewise.
* testsuite/25_algorithms/minmax/3.cc: Remove std::binary_function
base class.
* testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc:
Disable deprecated warnings.
* testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/count_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/count_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/find_end/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/find_end/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/find_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/find_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/for_each/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/for_each/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/partition/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/partition/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/search/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/search/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/25_algorithms/transform/requirements/explicit_instantiation/2.cc:
Likewise.
* testsuite/25_algorithms/transform/requirements/explicit_instantiation/pod.cc:
Likewise.
* testsuite/27_io/basic_filebuf/underflow/wchar_t/9178.cc: Add
dg-warning.
* testsuite/ext/pb_ds/example/priority_queue_erase_if.cc:
Likewise.
* testsuite/ext/pb_ds/example/priority_queue_split_join.cc:
Likewise.
* testsuite/tr1/3_function_objects/reference_wrapper/typedefs.cc:
Disable deprecated warnings.
* testsuite/tr1/6_containers/hash/requirements/base_classes.cc:
Likewise.
* testsuite/util/regression/trait/erase_if_fn.hpp: Remove
std::unary_function base classes.
* testsuite/util/testsuite_iterators.h (output_iterator_wrapper):
Remove std::iterator base classes.