Commit graph

14771 commits

Author SHA1 Message Date
Jonathan Wakely
f1dd83b720 libstdc++: Formatting std:🧵:id and std::stacktrace (P2693R1)
New std::formatter specializations for C++23.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (__cpp_lib_formatters): Define.
	* include/bits/version.h: Regenerate.
	* include/std/stacktrace (formatter<stacktrace_entry>)
	(formatter<basic_stacktrace<Alloc>>): Define.
	* include/std/thread (formatter<thread::id, charT>): Define.
	* testsuite/19_diagnostics/stacktrace/output.cc: New test.
	* testsuite/19_diagnostics/stacktrace/synopsis.cc: Add
	std::formatter specializations.
	* testsuite/19_diagnostics/stacktrace/version.cc: Check
	__cpp_lib_formatters macro.
	* testsuite/30_threads/thread/id/hash.cc: Remove gthreads
	dependency.
	* testsuite/30_threads/thread/id/operators.cc: Likewise.
	* testsuite/30_threads/thread/id/operators_c++20.cc: Likewise.
	* testsuite/30_threads/thread/id/output.cc: New test.
2023-09-11 14:56:58 +01:00
Pekka Seppänen
390fa3a78c libstdc++: Fix -Wunused-parameter warnings
Fix -Wunused-parameter warnings when _GLIBCXX_USE_WCHAR_T is not
defined.

libstdc++-v3/ChangeLog:

	* src/c++11/cow-locale_init.cc: Add [[maybe_unused]] attribute.
	* src/c++17/fs_path.cc (path::_S_convert_loc): Likewise.
	* src/filesystem/path.cc (path::_S_convert_loc): Likewise.

Signed-off-by: Pekka Seppänen <pexu@gcc.mail.kapsi.fi>
2023-09-11 12:36:18 +01:00
GCC Administrator
fd0b952111 Daily bump. 2023-09-09 00:16:40 +00:00
Jonathan Wakely
b96b554592 libstdc++: Add Filesystem TS and std::stacktrace symbols to libstdc++exp.a
This consolidates the three static archives for extensions into one, so
that -lstdc++exp can be used to provide the definitions of all unstable
library features.

The libstdc++_libbacktrace.a archive is now just a "noinst" convenience
library that is only used during the build, not installed. Its contents
are added to libstdc++exp.a, along with the new non-inline definitions
of std::stacktrace symbols.

The libstdc++fs.a archive is still installed, but its contents are
duplicated in libstdc++exp.a now. This means -lstdc++exp can be used
instead of -lstdc++fs. For targets using the GNU linker we should
consider replacing libstdc++fs.a with a linker script that does
INPUT(libstdc++exp.a).

The tests for <experimental/filesystem> could be changed to use
-lstdc++exp instead of -lstdc++fs, which would allow removing
src/filesystem/.libs from the LDFLAGS in scripts/testsuite_flags.in,
but that can be done at a later date.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CONFIGURE): Add c++23 directory.
	* configure: Regenerate.
	* doc/html/manual/*: Regenerate.
	* doc/xml/manual/using.xml: Update documentation on linking.
	* include/std/stacktrace: Remove declarations of libbacktrace
	APIs.
	(stacktrace_entry::_S_err_handler, stacktrace_entry::_S_init):
	Remove.
	(stacktrace_entry::_Info): New class.
	(stacktrace_entry::_M_get_info): Use _Info.
	(__stacktrace_impl): New class.
	(basic_stacktrace): Derive from __stacktrace_impl.
	(basic_stacktrace::current): Use __stacktrace_impl::_S_current.
	* scripts/testsuite_flags.in: Adjust LDFLAGS to find
	libstdc++exp instead of libstdc++_libbacktrace.
	* src/Makefile.am (SUBDIRS): Add c++23 directory.
	* src/Makefile.in: Regenerate.
	* src/c++20/Makefile.am: Fix comment.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++23/Makefile.am: New file.
	* src/c++23/Makefile.in: New file.
	* src/c++23/stacktrace.cc: New file with definitions of
	stacktrace_entry::_Info and __stacktrace_impl members.
	* src/experimental/Makefile.am: Use LIBADD to include other
	libraries.
	* src/experimental/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.am: Use noinst_LTLIBRARIES.
	* src/libbacktrace/Makefile.in: Regenerate.
	* testsuite/19_diagnostics/stacktrace/current.cc: Adjust
	dg-options to use -lstdc++exp.
	* testsuite/19_diagnostics/stacktrace/entry.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Likewise.
	* testsuite/23_containers/vector/debug/assign4_backtrace_neg.cc:
	Likewise.
2023-09-08 18:04:12 +01:00
Alexey Lapshin
1a0c6decd2 libstdc++: Fix unconditional -Werror in libbacktrace directory
The -Werror flag should depend on the --enable-werror configure option.

libstdc++-v3/ChangeLog:

	* src/libbacktrace/Makefile.am: Remove -Werror.
	* src/libbacktrace/Makefile.in: Regenerate.
2023-09-08 18:04:12 +01:00
Jonathan Wakely
67009f143f libstdc++: Reduce output of 'make check'
This removes the 39 lines of shell commands that get echoed when
starting the testsuite. The fact that near the end of that output it
prints `echo "WARNING: could not find \`runtest'" 1>&2; :;` makes it
look like that warning is actually being shown to the user.

Suppress echoing the recipe, so that users only see the actual output
from the testsuite, not the makefile recipe as well.

libstdc++-v3/ChangeLog:

	* testsuite/Makefile.am (check-DEJAGNU): Use @ in recipe.
	* testsuite/Makefile.in: Regenerate.
2023-09-08 18:04:12 +01:00
Yang Yujie
62a550e7ec LoongArch: Adjust C++ multilib header layout.
For LoongArch, the toplevel library build is always aliased to
one of the multilib variants.  This patch installs it with the
actual MULTISUBDIR (instead of ".") so that the headers can be
reached by the compiler.

This patch is an update of
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/629435.html

libstdc++-v3/ChangeLog:

	* configure.host: Register t-loongarch in tmake_file.
	* config/cpu/loongarch/t-loongarch: New file.  Manually refresh
	MULTISUBDIR with $(shell $(CXX) --print-multi-directory).
2023-09-08 17:51:06 +08:00
GCC Administrator
109c11f62b Daily bump. 2023-09-08 09:41:34 +00:00
Christophe Lyon
5ead44d0d0 Revert "libstdc++: Use GLIBCXX_CHECK_LINKER_FEATURES for cross-builds (PR111238)" 2023-09-08 08:44:53 +00:00
Bruno Victal
64fad6a494 libstdc++: Update docbook xsl URI
The URI for namespaced docbook-xsl was updated to reflect the current
DocBook upstream at <https://cdn.docbook.org/>.

libstdc++-v3/Changelog:

	* acinclude.m4: Update docbook xsl URI.
	* configure: Regenerate.
2023-09-07 17:50:49 +01:00
Bruno Victal
09c2815dc1 libstdc++: Fix 'doc-install-info' rule
The info manual isn't moved to the expected location after
generation which causes the install rule for it to fail.

libstdc++-v3/Changelog:

	* doc/Makefile.am: Fix 'doc-install-info' rule.
	Fix typo in commment.
	* doc/Makefile.in: Regenerate.
2023-09-07 17:50:46 +01:00
Jonathan Wakely
3b1b24fb2a libstdc++: Simplify dejagnu target selector
A target selector allows multiple target triplets, it's not necessary to
use the || operator in a logical expression.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/path/concat/94063.cc: Simplify
	dg-do target selector.
2023-09-07 17:05:54 +01:00
Jonathan Wakely
bd3d7e1146 libstdc++: Remove trailing whitespace from dejagnu files
Also fix the name of a source file used by an effective target check.

libstdc++-v3/ChangeLog:

	* testsuite/config/default.exp: Remove trailing whitespace.
	* testsuite/lib/dg-options.exp: Likewise.
	* testsuite/lib/prune.exp: Likewise.
	* testsuite/libstdc++-abi/abi.exp: Likewise.
	* testsuite/libstdc++-dg/conformance.exp: Likewise.
	* testsuite/libstdc++-prettyprinters/prettyprinters.exp:
	Likewise.
	* testsuite/libstdc++-xmethods/xmethods.exp: Likewise.
	* testsuite/lib/libstdc++.exp: Likewise.
	(check_v3_target_c_std): Fix filename for temporary source file.
2023-09-07 17:05:54 +01:00
Jonathan Wakely
5435449be0 libstdc++: Add autoconf checks for mkdir, chmod, chdir, and getcwd
The filesystem code was using these functions without checking for their
existence, assuming that any UNIX-like libc with <unistd.h> would always
provide them. That's not true for some newlib targets like arm-eabi.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for mkdir,
	chmod, chdir, and getcwd.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* src/c++17/fs_ops.cc (create_dir): Use USE_MKDIR macro.
	(fs::current_path): Use USE_GETCWD and USE_CHDIR macros.
	(fs::permissions): Use USE_CHMOD macro.
	* src/filesystem/ops-common.h [FILESYSTEM_IS_WINDOWS]
	(chmod, mkdir, getcwd, chdir): Define new macros.
	[FILESYSTEM_IS_WINDOWS] (chmod, mkdir, getcwd, chdir): Use
	new macros.
	* src/filesystem/ops.cc (create_dir): Use USE_MKDIR macro.
	(fs::current_path): Use USE_GETCWD and USE_CHDIR macros.
	(fs::permissions): Use USE_CHMOD macro.
2023-09-07 17:03:40 +01:00
Jonathan Wakely
d295a5341d libstdc++: Disable <stacktrace> support by default for avr
libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): Disable by default
	for avr.
	* configure: Regenerate.
2023-09-07 17:03:34 +01:00
Jonathan Wakely
b1ca841b89 libstdc++: Fix missing/misplaced { dg-options "-std=gnu++20" } in tests
These tests do not run by default, because the c++20 effective target
selector isn't matched.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/unordered_map/operations/1.cc: Add
	dg-options for C++20 mode.
	* testsuite/23_containers/unordered_multimap/operations/1.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/operations/1.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/operations/1.cc:
	Likewise.
	* testsuite/std/time/parse.cc: Move dg-options before dg-do.
2023-09-07 08:10:53 +01:00
Jonathan Wakely
f12e26f349 libstdc++: Fix <ranges> tests that fail in C++23
The tests for the std::ranges access CPOs (ranges::begin etc) use
pathological types with ridiculous overload sets for begin/end/data
members, to exercise all the corner cases in the specification.

Since P2278R4 "cbegin should always return a constant iterator" was
implemented for C++23 mode, some of the range access CPOs now require
the argument to satisfy the range concept, which was not previously
required. The behaviour of the CPO also changes for corner cases where
the type is a range R for which constant_range<R> is satisfied in
addition to constant_range<const R> (meaning there's no need to wrap its
iterators in const_iterator). Adjust the expected results for those
pathological types that changed meaning in C++23, and add some new types
to verify other corner cases.

Some other range adaptor tests fail for C++20 because they assert that
ranges::end and ranges::cend return different types, which is not true
when the type satisfies constant_range.

This fixes the tests to PASS for both C++20 and C++23 (and later).

libstdc++-v3/ChangeLog:

	* testsuite/std/ranges/access/cbegin.cc: Adjust for C++23
	compatibility.
	* testsuite/std/ranges/access/cdata.cc: Likewise.
	* testsuite/std/ranges/access/cend.cc: Likewise.
	* testsuite/std/ranges/access/crbegin.cc: Likewise.
	* testsuite/std/ranges/access/crend.cc: Likewise.
	* testsuite/std/ranges/adaptors/take.cc: Likewise.
	* testsuite/std/ranges/adaptors/take_while.cc: Likewise.
	* testsuite/std/ranges/adaptors/transform.cc: Likewise.
2023-09-07 08:09:58 +01:00
Jonathan Wakely
6854e3ac71 libstdc++: Simplify C++20 poison pill overloads (P2602R2)
This implements the C++23 change "Poison Pills are Too Toxic". This
makes sense to do unconditionally for C++20, as the corner cases that it
fixes are considered to be defects in the C++20 design (e.g. LWG3480 was
needed to fix directory iterators because of these pills being too
toxic).

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (__imove::iter_move): Define
	poison pill as deleted for consistency.
	(__access::begin): Replace with a single declaration.
	* include/bits/ranges_base.h (__access::end, __access::rbegin)
	(__access::rend, __access::size): Likewise.
	* include/bits/version.def (ranges): Update value for C++23.
	* include/bits/version.h: Regenerate.
	* libsupc++/compare (__compare): Add missing poison pill
	overloads.
	* testsuite/std/ranges/version_c++23.cc: Adjust expected value
	of __cpp_lib_ranges.
	* testsuite/std/ranges/access/p2602.cc: New test.
2023-09-07 08:08:12 +01:00
Jonathan Wakely
faea9d92db libstdc++: Rename C++20 Customization Point Objects
This makes the naming of the CPO types and namespaces simpler and more
consistent. With this change the string "cust" won't appear in
diagnostics related to these CPOs, which avoids confusion about what it
means (customization? customer?). Users don't really need to care that
these are called "customization point objects", so don't show them the
string "cust". Names like "__imove::_IterMove" are preferable to names
like "__cust_imove::_IMove" as the former is more obviously related to
the public API "ranges::iter_move".

Instead of a plethora of inline namespaces for all the different CPO
objects, define them all in an inline namespace called _Cpo (which isn't
shown to users anyway, unlike the types of those objects).

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (ranges::__cust_imove):
	Rename to ranges::__imove.
	(_IMove): Rename to _IterMove.
	(ranges::__cust_iswap): Rename to ranges::__iswap.
	(ranges::__cust): Rename to ranges::_Cpo.
	(ranges::__cust_access): Rename to ranges::__access.
	* include/bits/ranges_base.h (ranges::__cust_access): Rename to
	ranges::__access.
	(ranges::__cust): Rename to ranges::_Cpo.
	* include/std/concepts (ranges::__cust_swap):  Rename to
	ranges::__swap.
	(ranges::__cust): Rename to ranges::_Cpo.
	* libsupc++/compare (__cmp_cust): Rename to __compare.
	(__cmp_algo): Rename to _Cpo.
2023-09-07 08:05:51 +01:00
Jonathan Wakely
9f41791eff libstdc++: Relax range adaptors for move-only types (P2494R2)
This is a C++23 feature that relaxes the constraints on some range
adaptors, to support move-only types.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (ranges): Update value.
	* include/bits/version.h: Regenerate.
	* include/std/ranges (__detail::__boxable): Use
	move_constructible instead of copy_constructible for C++23.
	(__detail::__box<T>): Adjust constraints for partial
	specialization.
	(single_view, transform_view): Use __box_constructible instead
	of copy_constructible in constraints.
	(zip_transform_view, adjacent_transform_view, repeat_view): Use
	move_constructible instead of copy_constructible in constraints.
	* testsuite/std/ranges/adaptors/adjacent_transform/1.cc: Check
	construction from move-only argument.
	* testsuite/std/ranges/adaptors/transform.cc: Likewise.
	* testsuite/std/ranges/repeat/1.cc: Likewise.
	* testsuite/std/ranges/single_view.cc: Likewise.
	* testsuite/std/ranges/zip_transform/1.cc: Likewise.
	* testsuite/std/ranges/version_c++23.cc: Adjust expected value
	of __cpp_lib_ranges.
2023-09-07 08:05:15 +01:00
Jonathan Wakely
833733702a libstdc++: Avoid -Wunused-parameter warning in testsuite helper
libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_iterators.h (is_customization_point_object):
	Remove parameter name.
2023-09-07 08:02:49 +01:00
GCC Administrator
a134b6ce8e Daily bump. 2023-09-07 00:17:36 +00:00
Jonathan Wakely
6de5f5a4fe libstdc++: Disable <stacktrace> support by default for freestanding
libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): Disable by default
	for freestanding.
	* configure: Regenerate.
2023-09-06 23:14:26 +01:00
GCC Administrator
d820cd785b Daily bump. 2023-09-05 13:34:14 +00:00
Christophe Lyon
084a7cf9fb Revert "libstdc++: Use GLIBCXX_CHECK_LINKER_FEATURES for cross-builds (PR111238)"
This reverts commit 46c2e94ca66ed9991c45a6ba6204ed02869efc39.
2023-09-04 20:44:20 +00:00
Christophe Lyon
56d0592db1 libstdc++: Use GLIBCXX_CHECK_LINKER_FEATURES for cross-builds (PR111238)
As discussed in PR104167 (comments #8 and below), and PR111238, using
-Wl,-gc-sections in the libstdc++ testsuite for arm-eabi
(cross-toolchain) avoids link failures for a few tests:

27_io/filesystem/path/108636.cc
std/time/clock/gps/1.cc
std/time/clock/gps/io.cc
std/time/clock/tai/1.cc
std/time/clock/tai/io.cc
std/time/clock/utc/1.cc
std/time/clock/utc/io.cc
std/time/clock/utc/leap_second_info.cc
std/time/exceptions.cc
std/time/format.cc
std/time/time_zone/get_info_local.cc
std/time/time_zone/get_info_sys.cc
std/time/tzdb/1.cc
std/time/tzdb/leap_seconds.cc
std/time/tzdb_list/1.cc
std/time/zoned_time/1.cc
std/time/zoned_time/custom.cc
std/time/zoned_time/io.cc
std/time/zoned_traits.cc

This patch achieves this by calling GLIBCXX_CHECK_LINKER_FEATURES in
cross-build cases, like we already do for native builds. We keep not
doing so in Canadian-cross builds.

However, this would hide the fact that libstdc++ somehow forces the
user to use -Wl,-gc-sections to avoid undefined references to chdir,
mkdir, chmod, pathconf, ... so maybe it's better to keep the status
quo and not apply this patch?

2023-08-31  Christophe Lyon  <christophe.lyon@linaro.org>

libstdc++-v3/ChangeLog:

	PR libstdc++/111238
	* configure: Regenerate.
	* configure.ac: Call GLIBCXX_CHECK_LINKER_FEATURES in cross,
	non-Canadian builds.
2023-09-04 20:44:20 +00:00
Jonathan Wakely
270e702eda libstdc++: Remove unnecessary dg-options and outdated comment
It's no longer true that 1.0if has type float _Complex when GNU
extensions are enabled, so remove the hardcoded -std option.

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/complex/literals/types.cc: Remove
	dg-options and add target selector instead.
2023-09-04 16:24:35 +01:00
Jonathan Wakely
455907564c libstdc++: Remove dg-options "-std=c++98" from TR1 tests
These tests need slight adjustments to be valid in C++11 and later, but
there's no reason that can't be done, so that we test them in more
modes.

libstdc++-v3/ChangeLog:

	* testsuite/tr1/6_containers/utility/pair.cc: Remove dg-options
	and qualify ambiguous calls to get.
	* testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc: Adjust
	expected result for std::pow(float, int) as per DR 550.
2023-09-04 16:24:35 +01:00
Jonathan Wakely
678834e9ff libstdc++: Enable std::auto_ptr tests for C++11 and later
There is no reason to only test std::auto_ptr with -std=c++03, we just
need to handle the deprecated warnings for C++11 and later.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/auto_ptr/1.cc: Remove dg-options -std=c++03
	and add dg-warning for deprecation warnings.
	* testsuite/20_util/auto_ptr/2.cc: Likewise.
	* testsuite/20_util/auto_ptr/3.cc: Likewise.
	* testsuite/20_util/auto_ptr/3946.cc: Likewise.
	* testsuite/20_util/auto_ptr/4.cc: Likewise.
	* testsuite/20_util/auto_ptr/5.cc: Likewise.
	* testsuite/20_util/auto_ptr/6.cc: Likewise.
	* testsuite/20_util/auto_ptr/7.cc: Likewise.
	* testsuite/20_util/auto_ptr/assign_neg.cc: Likewise.
	* testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_neg.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_rvalue_neg.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr_neg.cc:
	Likewise.
2023-09-04 16:24:35 +01:00
Jonathan Wakely
affbb7b432 libstdc++: Fix filenames and comments in tests [PR26142]
These tests have transposed digits in the filenames and comments.

libstdc++-v3/ChangeLog:

	PR libstdc++/26142
	* testsuite/23_containers/vector/26412-1.cc: Moved to...
	* testsuite/23_containers/vector/26142-1.cc: ...here.
	* testsuite/23_containers/vector/26412-2.cc: Moved to...
	* testsuite/23_containers/vector/26142-2.cc: ...here.
2023-09-04 16:24:35 +01:00
Jonathan Wakely
4bbe1414e1 libstdc++: Add { target c++98_only } to tests
These test behaviour only seen with -std=c++03 so the target selector
should match.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/bitset/107037.cc: Add c++98_only selector.
	* testsuite/26_numerics/complex/56111.cc: Likewise.
2023-09-04 16:24:34 +01:00
Jonathan Wakely
0eb35092de libstdc++: Add explicit -std=gnu++98 to tests that use { target c++98_only }
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/deque/requirements/explicit_instantiation/2.cc:
	Add dg-options to restrict the test to C++98 mode.
	* testsuite/23_containers/list/requirements/explicit_instantiation/2.cc:
	Likewise.
2023-09-04 16:04:26 +01:00
Jonathan Wakely
c34ad4bc19 libstdc++: Add missing target selector to std::expected test
This test should use a target selector of c++23 so that the explicit
-std=gnu++23 option can be removed, to allow testing with later
standards too.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/expected/bad.cc: Add missing target
	selector.
2023-09-04 16:04:26 +01:00
GCC Administrator
80907b03c8 Daily bump. 2023-09-02 00:17:36 +00:00
Jonathan Wakely
b0d75f7d3b libstdc++: Fix debug-mode tests for constexpr algorithms
These tests started failing at some point:
FAIL: 25_algorithms/copy/debug/constexpr_neg.cc  (test for errors, line 49)
FAIL: 25_algorithms/copy/debug/constexpr_neg.cc (test for excess errors)
FAIL: 25_algorithms/equal/debug/constexpr_neg.cc  (test for errors, line 47)
FAIL: 25_algorithms/equal/debug/constexpr_neg.cc (test for excess errors)

They only run with -D_GLIBCXX_DEBUG or make check-debug so seem to have
gone unnoticed until now.

libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/copy/debug/constexpr_neg.cc: Adjust
	expected errors.
	* testsuite/25_algorithms/equal/debug/constexpr_neg.cc:
	Likewise.
2023-09-01 17:52:41 +01:00
Jonathan Wakely
e3d25188b0 libstdc++: Add -Wno-self-move to two filesystem tests
libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/iterators/91067.cc: Add
	-Wno-self-move to options.
	* testsuite/27_io/filesystem/path/assign/copy.cc: Likewise.
2023-09-01 17:52:41 +01:00
Vladimir Palevich
419c423d3a libstdc++: fix memory clobbering in std::vector [PR110879]
Fix ordering to prevent clobbering of class members by a call to deallocate
in _M_realloc_insert and _M_default_append.

Because of recent changes in _M_realloc_insert and _M_default_append,
calls to deallocate were ordered after assignment to class members of
std::vector (in the guard destructor), which is causing said members to
be call-clobbered.  This is preventing further optimization, the
compiler is unable to move memory read out of a hot loop in this case.

This patch reorders the call to before assignments by putting guard in
its own block. Plus a new testsuite for this case.  I'm not very happy
with the new testsuite, but I don't know how to properly test this.

	PR libstdc++/110879

libstdc++-v3/ChangeLog:

	* include/bits/vector.tcc (_M_realloc_insert): End guard
	lifetime just before assignment to class members.
	(_M_default_append): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/pr110879.C: New test.

Signed-off-by: Vladimir Palevich  <palevichva@gmail.com>
2023-09-01 16:01:23 +01:00
Jonathan Wakely
283994cba6 libstdc++: Use std::string::__resize_and_overwrite in std::filesystem
There are a few places in the std::filesystem code that use a string as
a buffer for OS APIs to write to. We can use the new extension
__resize_and_overwrite to avoid redundant initialization of those
buffers.

libstdc++-v3/ChangeLog:

	* src/c++17/fs_ops.cc (fs::absolute) [FILESYSTEM_IS_WINDOWS]:
	Use __resize_and_overwrite to fill buffer.
	(fs::read_symlink) [HAVE_READLINK]: Likewise.
	* src/filesystem/ops-common.h (get_temp_directory_from_env)
	[FILESYSTEM_IS_WINDOWS]: Likewise.
2023-09-01 16:01:23 +01:00
Jonathan Wakely
dcbec954fc libstdc++: Use a loop in atomic_ref::compare_exchange_strong [PR111077]
We need to use a loop in std::atomic_ref::compare_exchange_strong in
order to properly implement the C++20 requirement that padding bits do
not participate when checking the value for equality. The variable being
modified by a std::atomic_ref might have an initial value with non-zero
padding bits, so when the __atomic_compare_exchange built-in returns
false we need to check whether that was only because of non-equal
padding bits that are not part of the value representation. If the value
bits differ, it's just a failed compare-exchange. If the value bits are
the same, we need to retry the __atomic_compare_exchange using the value
that was just read by the previous failed call. As noted in the
comments, it's possible for that second try to also fail due to another
thread storing the same value but with differences in padding.

Because it's undefined to access a variable directly while it's held by
a std::atomic_ref, and because std::atomic_ref will only ever store
values with zeroed padding, we know that padding bits will never go from
zero to non-zero during the lifetime of a std::atomic_ref. They can only
go from an initial non-zero state to zero. This means the loop will
terminate, rather than looping indefinitely as padding bits flicker on
and off. In theory users could call __atomic_store etc. directly and
write a value with non-zero padding bits, but we don't need to support
that. Users doing that should ensure they do not write non-zero padding,
to be compatibile with our std::atomic_ref's invariants.

This isn't a problem for std::atomic<T>::compare_exchange_strong because
the initial value (and all later stores to the variable) are performed
by the library, so we ensure that stored values always have padding bits
cleared. That means we can simply clear the padding bits of the
'expected' value and we will be comparing two values with equal padding
bits. This means we don't need the loop for std::atomic, so update the
__atomic_impl::__compare_exchange function to take a bool parameter that
says whether it's being used by std::atomic_ref. If not, we can use a
simpler, non-looping implementation.

libstdc++-v3/ChangeLog:

	PR libstdc++/111077
	* include/bits/atomic_base.h (__atomic_impl::__compare_exchange):
	Add _AtomicRef non-type template parameter and use a loop if it
	is true.
	(__atomic_impl::compare_exchange_weak): Add _AtomicRef NTTP.
	(__atomic_impl::compare_exchange_strong): Likewise.
	(atomic_ref::compare_exchange_weak): Use true for NTTP.
	(atomic_ref::compare_exchange_strong): Use true for NTTP.
	* testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc:
	Fix test to not rely on atomic_ref::load() to return an object
	with padding preserved.
2023-09-01 16:01:18 +01:00
Jonathan Wakely
c07d82c12f libstdc++: Use dg-require-filesystem-ts in link test
This test expects to be able to link, which fails if there are undefined
references to chdir, mkdir etc. in fs_ops.o in the libstdc++.a archive.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/path/108636.cc: Add dg-require for
	filesystem support.
2023-09-01 12:13:34 +01:00
Jonathan Wakely
f2eb6132c6 libstdc++: Avoid useless dependency on read_symlink from tzdb
chrono::tzdb::current_zone uses filesystem::read_symlink, which creates
a dependency on the fs_ops.o object in libstdc++.a, which then creates
dependencies on several OS functions if --gc-sections isn't used. For
more details see PR libstdc++/104167 comment 8 and comment 11.

In the cases where that causes linker failures, we probably don't have
readlink anyway, so the filesystem::read_symlink call will always fail.
Repeat the preprocessor conditions for filesystem::read_symlink in the
body of chrono::tzdb::current_zone so that we don't create a
dependency on fs_ops.o for a function that will always fail.

libstdc++-v3/ChangeLog:

	* src/c++20/tzdb.cc (tzdb::current_zone): Check configure macros
	for POSIX readlink before using filesystem::read_symlink.
2023-09-01 12:13:34 +01:00
Jonathan Wakely
fcede95472 libstdc++: Make --enable-libstdcxx-backtrace=auto default to yes
This causes libstdc++_libbacktrace.a to be built by default. This might
fail on some targets, in which case we can make the 'auto' choice expand
to either 'yes' or 'no' depending on the target.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): Default to yes.
	* configure: Regenerate.
2023-09-01 12:13:33 +01:00
Jonathan Wakely
e5af77adef libstdc++: Fix how chrono::parse handles errors for time-of-day values
We fail to diagnose an error and extract an incorrect time for cases
like "25:59" >> parse("%H:%M", mins). The bad "25" hour value gets
ignored (on the basis that we might not care about it if trying to
extract something like a weekday or a month name), but then when we get
to the end of the function we think we have a valid time from "59" and
so the result is 00:59.

The problem is that the '__bad_h' value is used for "no hour value read
yet" as well as "bad hour value read". If we just set __h = __bad_h and
continue, we can't tell later that we read an invalid hour.

The fix is to set failbit early when we're trying to extract a
time-of-day (e.g. duration or time_point) and we encounter an invalid
hour, minute, or second value. We can still delay other error checking
to the end.

libstdc++-v3/ChangeLog:

	* include/bits/chrono_io.h (_Parser::operator()): Set failbit
	early if invalid values are read when _M_need & _TimeOfDay is
	non-zero.
	* testsuite/std/time/parse.cc: Check that "25:59" cannot be
	parsed for "%H:%M".
2023-09-01 09:55:48 +01:00
Jonathan Wakely
207c507499 libstdc++: Do not allow chrono::parse to overflow for %C [PR111162]
libstdc++-v3/ChangeLog:

	PR libstdc++/111162
	* include/bits/chrono_io.h (_Parser::Operator()): Check %C
	values are in range of year::min() to year::max().
	* testsuite/std/time/parse.cc: Check out of range centuries.
2023-09-01 09:55:48 +01:00
Jonathan Wakely
17a371d05a libstdc++: Simplify __format::_Sink::_M_reset
Using an offset as the second argument instead of an iterator makes it
easier for callers, as they don't need to create an lvalue span in order
to get an iterator from it for the _M_reset call.

libstdc++-v3/ChangeLog:

	* include/std/format (__format::_Sink::_M_reset): Change second
	argument from iterator to offset.
2023-09-01 09:55:48 +01:00
GCC Administrator
6d47c9b418 Daily bump. 2023-08-25 00:18:19 +00:00
Paul Dreik
7564fe9865 libstdc++: Add test for illegal pointer arithmetic in format [PR111102]
libstdc++-v3/ChangeLog:

	PR libstdc++/111102
	* testsuite/std/format/string.cc: Check wide character format
	strings with out-of-range widths.
2023-08-24 13:44:39 +01:00
Paul Dreik
dd4bdb9eea libstdc++: fix illegal pointer arithmetic in format [PR111102]
When parsing a format string, the width is parsed into an unsigned short
but the result is not checked in the case the format string is not a
char string (such as a wide string). In case the parse fails, a null
pointer is returned which is used for pointer arithmetic which is
undefined behaviour.

Signed-off-by: Paul Dreik <gccpatches@pauldreik.se>

libstdc++-v3/ChangeLog:

	PR libstdc++/111102
	* include/std/format (__format::__parse_integer): Check for
	non-null pointer.
2023-08-24 13:44:38 +01:00
Jonathan Wakely
d6271d600d libstdc++: Fix -Wunused-but-set-variable in std::format_to test
libstdc++-v3/ChangeLog:

	* testsuite/std/format/functions/format_to.cc: Avoid warning for
	unused variables.
2023-08-24 13:44:38 +01:00
Jonathan Wakely
e64ad2c84f libstdc++: Tweak some preprocessor conditions for feature tests
Update a preprocessor condition using __cplusplus and _GLIBCXX_HOSTED
to use the relevant feature test macro for <syncstream>.

Also add comments to some conditions saying which C++ standard revision
the check corresponds to.

libstdc++-v3/ChangeLog:

	* include/std/atomic: Add comment to #ifdef and fix indentation.
	* include/std/ostream: Check __glibcxx_syncbuf instead of
	__cplusplus and _GLIBCXX_HOSTED.
	* include/std/thread: Add comment to #ifdef.
2023-08-24 13:44:38 +01:00