Commit graph

15075 commits

Author SHA1 Message Date
Jonathan Wakely
07e03761a7 libstdc++: Fix infinite loop in std::binomial_distribution [PR114359]
The multiplication (4 * _M_t * __1p) can wraparound to zero if _M_t is
unsigned and 4 * _M_t wraps to zero. The third operand has type double,
so do the second multiplication first, so that we aren't multiplying
integers.

libstdc++-v3/ChangeLog:

	PR libstdc++/114359
	* include/bits/random.tcc (binomial_distribution::param_type):
	Ensure arithmetic is done as type double.
	* testsuite/26_numerics/random/binomial_distribution/114359.cc: New test.
2024-03-19 15:59:44 +00:00
Jonathan Wakely
c608b57f77 libstdc++: Suppress deprecation messages from <tbb/task.h> [PR101228]
libstdc++-v3/ChangeLog:

	PR libstdc++/101228
	* include/pstl/parallel_backend_tbb.h (TBB_SUPPRESS_DEPRECATED_MESSAGES):
	Define before including <tbb/task.h> then undef afterwards.
2024-03-19 15:59:44 +00: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
d1b8c2237d libstdc++: Update docs on build process and generated files
There are several more sub-directories below 'src' now, with lots more
conveience libraries. Document them all as of GCC 14.

Also document how to regenerate the generated headers under include/bits
and how to update the tzdata.zi file.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/build_hacking.xml: Document generated files.
	Update list of convenience libraries and sub-directories under
	the src directory.
	* doc/html/*: Regenerate.
2024-03-19 15:20:07 +00:00
Jonathan Wakely
ef2efc53fd libstdc++: Fix Python scripts to output the correct filename
These scripts both print "generated by $file, do not edit" header but
one of them prints the wrong filename. Use the built-in __file__
attribute to ensure it's correct.

contrib/ChangeLog:

	* unicode/gen_libstdcxx_unicode_data.py: Fix header of generated
	file to name the correct script.

libstdc++-v3/ChangeLog:

	* include/bits/text_encoding-data.h: Regenerate.
	* include/bits/unicode-data.h: Regenerate.
	* scripts/gen_text_encoding_data.py: Fix header of generated
	file to name the correct script.
2024-03-19 15:20:07 +00:00
Jonathan Wakely
f5118546a8 libstdc++: Fix typos in MemoryChecker assertion messages in PSTL tests
This has been reported upstream.

libstdc++-v3/ChangeLog:

	* testsuite/util/pstl/test_utils.h: Fix typos in comments.
2024-03-19 15:20:07 +00:00
Jonathan Wakely
16afbd9c9c libstdc++: Begin lifetime of storage in std::vector<bool> [PR114367]
This doesn't cause a problem with GCC, but Clang correctly diagnoses a
bug in the code. The objects in the allocated storage need to begin
their lifetime before we start using them.

This change uses the allocator's construct function instead of using
std::construct_at directly, in order to support fancy pointers.

libstdc++-v3/ChangeLog:

	PR libstdc++/114367
	* include/bits/stl_bvector.h (_M_allocate): Use allocator's
	construct function to begin lifetime of words.
2024-03-19 15:13:18 +00:00
Iain Sandoe
71a44faa8a libstdc++: Sync the atomic_link_flags implementation with GCC.
For Darwin, in order to allow uninstalled testing, we need to provide
a '-B' option pointing to each path containing an uninstalled library
that we are using (these get appended to the embedded runpaths).

This updates the version of the atomic_link_flags proc in the libstdc++
testsuite to do the same as the one in the GCC testsuite.

libstdc++-v3/ChangeLog:

	* testsuite/lib/dg-options.exp (atomic_link_flags): Emit a -B
	option for the path to the uninstalled libatomic.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-03-19 12:53:31 +00:00
Iain Sandoe
e47330d074 libstdc++, Darwin: Do not use dev/null as the file for executables.
Darwin has a separate debug linker, which is invoked when the command
line contains source files and debug is enabled.

Using /dev/null as the executable name does not, therefore, work when
debug is enabled, since the debug linker does not accept /dev/null as
a valid executable name.

The leads to incorrectly UNSUPPORTED testcases because of the unintended
error result from the test compilation.

The solution here is to use a temporary file that is deleted at the
end of the test (which is the mechanism used elsewhere)

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (v3_target_compile): Instead of
	/dev/null, use a temporary file for test executables on Darwin.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-03-19 12:48:32 +00:00
GCC Administrator
23409731ca Daily bump. 2024-03-19 00:18:16 +00:00
François Dumont
dda96a9d94 libstdc++: Fix N3344 behavior on _Safe_iterator::_M_can_advance
We shall be able to advance from a 0 offset a value-initialized iterator.

libstdc++-v3/ChangeLog:

	* include/debug/safe_iterator.tcc (_Safe_iterator<>::_M_can_advance):
	Accept 0 offset advance on value-initialized iterator.
	* testsuite/23_containers/vector/debug/n3644.cc: New test case.
2024-03-18 22:30:55 +01:00
François Dumont
5f6e0853c3 libstdc++: Fix _Safe_local_iterator<>::_M_valid_range
Unordered container local_iterator range shall not contain any singular
iterator unless both iterators are both value-initialized.

libstdc++-v3/ChangeLog:

	* include/debug/safe_local_iterator.tcc
	(_Safe_local_iterator::_M_valid_range): Add _M_value_initialized and
	_M_singular checks.
	* testsuite/23_containers/unordered_set/debug/114316.cc: New test case.
2024-03-18 22:25:57 +01:00
GCC Administrator
27d2e933a0 Daily bump. 2024-03-18 00:16:48 +00:00
François Dumont
07fad7a7fc libstdc++: Implement N3644 on _Safe_iterator<> [PR114316]
Consider range of value-initialized iterators as valid and empty.

libstdc++-v3/ChangeLog:

	PR libstdc++/114316
	* include/debug/safe_iterator.tcc (_Safe_iterator<>::_M_valid_range):
	First check if both iterators are value-initialized before checking if
	singular.
	* testsuite/23_containers/set/debug/114316.cc: New test case.
	* testsuite/23_containers/vector/debug/114316.cc: New test case.
2024-03-17 16:41:37 +01:00
GCC Administrator
c1f6690b82 Daily bump. 2024-03-15 00:17:52 +00:00
Jonathan Wakely
f89cfdb2f2 libstdc++: Fix std::format("{}", negative_integer) [PR114325]
The fast path for "{}" format strings has a bug for negative integers
where the length passed to std::to_chars is too long.

libstdc++-v3/ChangeLog:

	PR libstdc++/114325
	* include/std/format (_Scanner::_M_scan): Pass correct length to
	__to_chars_10_impl.
	* testsuite/std/format/functions/format.cc: Check negative
	integers with empty format-spec.
2024-03-14 16:58:15 +00:00
Jonathan Wakely
df483ebd24 libstdc++: Add nodiscard in <algorithm>
Add the [[nodiscard]] attribute to several functions in <algorithm>.
These all have no side effects and are only called for their return
value (e.g. std::count) or produce a result that must not be discarded
for correctness (e.g. std::remove).

I was intending to add the attribute to a number of other functions like
std::copy_if, std::unique_copy, std::set_union, and std::set_difference.
I stopped when I noticed that MSVC doesn't use it on those functions,
which I suspect is because they're often used with an insert iterator
(e.g. std::back_insert_iterator). In that case it doesn't matter if
you discard the result, because you have the container to tell you how
many elements were copied to the output range.

libstdc++-v3/ChangeLog:

	* include/bits/stl_algo.h (find_end, all_of, none_of, any_of)
	(find_if_not, is_partitioned, partition_point, remove)
	(remove_if, unique, lower_bound, upper_bound, equal_range)
	(binary_search, includes, is_sorted, is_sorted_until, minmax)
	(minmax_element, is_permutation, clamp, find_if, find_first_of)
	(adjacent_find, count, count_if, search, search_n, min_element)
	(max_element): Add nodiscard attribute.
	* include/bits/stl_algobase.h (min, max, lower_bound, equal)
	(lexicographical_compare, lexicographical_compare_three_way)
	(mismatch): Likewise.
	* include/bits/stl_heap.h (is_heap, is_heap_until): Likewise.
	* testsuite/25_algorithms/equal/debug/1_neg.cc: Add dg-warning.
	* testsuite/25_algorithms/equal/debug/2_neg.cc: Likewise.
	* testsuite/25_algorithms/equal/debug/3_neg.cc: Likewise.
	* testsuite/25_algorithms/find_first_of/concept_check_1.cc:
	Likewise.
	* testsuite/25_algorithms/is_permutation/2.cc: Likewise.
	* testsuite/25_algorithms/lexicographical_compare/71545.cc:
	Likewise.
	* testsuite/25_algorithms/lower_bound/33613.cc: Likewise.
	* testsuite/25_algorithms/lower_bound/debug/irreflexive.cc:
	Likewise.
	* testsuite/25_algorithms/lower_bound/debug/partitioned_neg.cc:
	Likewise.
	* testsuite/25_algorithms/lower_bound/debug/partitioned_pred_neg.cc:
	Likewise.
	* testsuite/25_algorithms/minmax/3.cc: Likewise.
	* testsuite/25_algorithms/search/78346.cc: Likewise.
	* testsuite/25_algorithms/search_n/58358.cc: Likewise.
	* testsuite/25_algorithms/unique/1.cc: Likewise.
	* testsuite/25_algorithms/unique/11480.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/33613.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/debug/partitioned_neg.cc:
	Likewise.
	* testsuite/25_algorithms/upper_bound/debug/partitioned_pred_neg.cc:
	Likewise.
	* testsuite/ext/concept_checks.cc: Likewise.
	* testsuite/ext/is_heap/47709.cc: Likewise.
	* testsuite/ext/is_sorted/cxx0x.cc: Likewise.
2024-03-14 16:58:15 +00:00
xndcn
0adc8c5f14 libstdc++: Add missing clear_padding in __atomic_float constructor
For 80-bit long double we need to clear the padding bits on
construction.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h (__atomic_float::__atomic_float(Fp)):
	Clear padding.
	* testsuite/29_atomics/atomic_float/compare_exchange_padding.cc:
	New test.

Signed-off-by: xndcn <xndchn@gmail.com>

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-03-14 15:06:47 +00:00
Jonathan Wakely
e6836bbbd7 libstdc++: Correct notes about std::call_once in manual [PR66146]
The bug with exceptions thrown during a std::call_once call affects all
targets, so fix the docs that say it only affects non-Linux targets.

libstdc++-v3/ChangeLog:

	PR libstdc++/66146
	* doc/xml/manual/status_cxx2011.xml: Remove mention of Linux in
	note about std::call_once.
	* doc/xml/manual/status_cxx2014.xml: Likewise.
	* doc/xml/manual/status_cxx2017.xml: Likewise.
	* doc/html/manual/status.html: Regenerate.
2024-03-14 11:54:32 +00:00
Jonathan Wakely
2a556dbec2 libstdc++: Update C++23 status in the manual
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2023.xml: Update C++23 status table.
	* doc/html/manual/status.html: Regenerate.
	* include/bits/version.def: Fix typo in comment.
2024-03-14 11:54:32 +00:00
GCC Administrator
746b71e26b Daily bump. 2024-03-14 00:18:12 +00:00
Jonathan Wakely
a8c7c3a409 libstdc++: Move test error_category to global scope
A recent GDB change causes this test to fail due to missing RTTI for the
custom_cast type. This is presumably because the custom_cat type was
defined as a local class, so has no linkage. Moving it to local scope
seems to fix the test regressions, and probably makes the test more
realistic as a local class with no linkage isn't practical to use as an
error category that almost certainly needs to be referred to in other
scopes.

libstdc++-v3/ChangeLog:

	* testsuite/libstdc++-prettyprinters/cxx11.cc: Move custom_cat
	to namespace scope.
2024-03-13 21:25:14 +00:00
Jonathan Wakely
45a3ee8a40 libstdc++: Improve documentation on debugging with libstdc++
libstdc++-v3/ChangeLog:

	* doc/xml/manual/debug.xml: Improve docs on debug builds and
	using ASan. Mention _GLIBCXX_ASSERTIONS. Reorder sections to put
	the most relevant ones first.
	* doc/xml/manual/using.xml: Add comma.
	* doc/html/*: Regenerate.
2024-03-13 21:25:14 +00:00
Jonathan Wakely
d6490157b3 libstdc++: Document that _GLIBCXX_CONCEPT_CHECKS might be removed in future
The macro-based concept checks are unmaintained and do not support C++11
or later, so reject valid code. If nobody plans to update them we should
consider removing them. Alternatively, we could ignore the macro for
C++11 and later, so they have no effect and don't reject valid code.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/debug.xml: Document that concept checking might
	be removed in future.
	* doc/xml/manual/extensions.xml: Likewise.
2024-03-13 21:25:13 +00:00
GCC Administrator
3e05eb949d Daily bump. 2024-03-10 00:17:04 +00:00
Jonathan Wakely
3e8ee03edd libstdc++: Do not require a time-of-day when parsing sys_days [PR114240]
When parsing a std::chrono::sys_days (or a sys_time with an even longer
period) we should not require a time-of-day to be present in the input,
because we can't represent that in the result type anyway.

Rather than trying to decide which specializations should require a
time-of-date and which should not, follow the direction of Howard
Hinnant's date library, which allows extracting a sys_time of any period
from input that only contains a date, defaulting the time-of-day part to
00:00:00. This seems consistent with the intent of the standard, which
says it's an error "If the parse fails to decode a valid date" (i.e., it
doesn't care about decoding a valid time, only a date).

libstdc++-v3/ChangeLog:

	PR libstdc++/114240
	* include/bits/chrono_io.h (_Parser::operator()): Assume
	hours(0) for a time_point, so that a time is not required
	to be present.
	* testsuite/std/time/parse/114240.cc: New test.
2024-03-09 00:21:42 +00:00
Jonathan Wakely
f4a52c184d libstdc++: Fix parsing of leap seconds as chrono::utc_time [PR114279]
Implementing all chrono::from_stream overloads in terms of
chrono::sys_time meant that a leap second time like 23:59:60.001 cannot
be parsed, because that cannot be represented in a sys_time.

The fix to support parsing leap seconds as utc_time is to convert the
parsed date to utc_time<days> and then add the parsed time to that,
which allows the result to land in a leap second, rather than doing all
the arithmetic with sys_time which doesn't have leap seconds.

For local_time we also allow %S to parse a 60s value, because doing
otherwise might disallow some valid uses. We can't know all use cases
users have for treating times as local_time.

For all other clocks, we can reject times that have 60 or 60.nnn as the
seconds part, because that cannot occur in a valid UNIX, GPS, or TAI
time. Since our chrono::file_clock uses sys_time, it can't occur for
that clock either.

In order to support this a new _M_is_leap_second member is needed in the
_Parser type. This can be added at the end, where most targets currently
have padding bytes. Similar to what I did recently for formatter _Spec
structs, we can also reserve additional padding bits for future
expansion.

This also fixes bugs in the from_stream overloads for utc_time,
tai_time, gps_time, and file_time, which were not using time_point_cast
to explicitly convert to the result type. That's needed because the
result type might have lower precision than the value returned from
from_sys or from_utc, which has a precision no lower than seconds.

libstdc++-v3/ChangeLog:

	PR libstdc++/114279
	* include/bits/chrono_io.h (_Parser::_M_is_leap_second): New
	data member.
	(_Parser::_M_reserved): Reserve padding bits for future use.
	(_Parser::operator()): Set _M_is_leap_second if %S reads 60s.
	(from_stream): Only allow _M_is_leap_second for utc_time and
	local_time. Adjust arithmetic for utc_time so that leap seconds
	are preserved. Use time_point_cast to convert to a possibly
	lower-precision result type.
	* testsuite/std/time/parse.cc: Move to ...
	* testsuite/std/time/parse/parse.cc: ... here.
	* testsuite/std/time/parse/114279.cc: New test.
2024-03-09 00:21:42 +00:00
GCC Administrator
1e74c758a2 Daily bump. 2024-03-08 00:17:33 +00:00
Jonathan Wakely
715127b63d libstdc++: Use std::from_chars to speed up parsing subsecond durations
With std::from_chars we can parse subsecond durations much faster than
with std::num_get, as shown in the microbenchmarks below. We were using
std::num_get and std::numpunct in order to parse a number with the
locale's decimal point character. But we copy the chars from the input
stream into a new buffer anyway, so we can replace the locale's decimal
point with '.' in that buffer, and then we can use std::from_chars on
it.

Benchmark                Time             CPU   Iterations
----------------------------------------------------------
from_chars_millisec    158 ns          158 ns      4524046
num_get_millisec       192 ns          192 ns      3644626
from_chars_microsec    164 ns          163 ns      4330627
num_get_microsec       205 ns          205 ns      3413452
from_chars_nanosec     173 ns          173 ns      4072653
num_get_nanosec        227 ns          227 ns      3105161

libstdc++-v3/ChangeLog:

	* include/bits/chrono_io.h (_Parser::operator()): Use
	std::from_chars to parse fractional seconds.
2024-03-07 23:50:39 +00:00
Jonathan Wakely
5f9d7a5b6c libstdc++: Fix parsing of fractional seconds [PR114244]
When converting a chrono::duration<long double> to a result type with an
integer representation we should use chrono::round<_Duration> so that we
don't truncate towards zero. Rounding ensures that e.g. 0.001999s
becomes 2ms not 1ms.

We can also remove some redundant uses of chrono::duration_cast to
convert from seconds to _Duration, because the _Parser class template
requires _Duration type to be able to represent seconds without loss of
precision.

This also fixes a bug where no fractional part would be parsed for
chrono::duration<long double> because its period is ratio<1>. We should
also consider treat_as_floating_point<rep> when deciding whether to skip
reading a fractional part.

libstdc++-v3/ChangeLog:

	PR libstdc++/114244
	* include/bits/chrono_io.h (_Parser::operator()): Remove
	redundant uses of duration_cast. Use chrono::round to convert
	long double value to durations with integer representations.
	Check represenation type when deciding whether to skip parsing
	fractional seconds.
	* testsuite/20_util/duration/114244.cc: New test.
	* testsuite/20_util/duration/io.cc: Check that a floating-point
	duration with ratio<1> precision can be parsed.
2024-03-07 22:52:49 +00:00
Jonathan Wakely
e162b2ff52 libstdc++: Do not define lock-free atomic aliases if not fully lock-free [PR114103]
The whole point of these typedefs is to guarantee lock-freedom, so if
the target has no such types, we shouldn't defined the typedefs at all.

libstdc++-v3/ChangeLog:

	PR libstdc++/114103
	* include/bits/version.def (atomic_lock_free_type_aliases): Add
	extra_cond to check for at least one always-lock-free type.
	* include/bits/version.h: Regenerate.
	* include/std/atomic (atomic_signed_lock_free)
	(atomic_unsigned_lock_free): Only use always-lock-free types.
	* src/c++20/tzdb.cc (time_zone::_Impl::RulesCounter): Don't use
	atomic counter if lock-free aliases aren't available.
	* testsuite/29_atomics/atomic/lock_free_aliases.cc: XFAIL for
	targets without lock-free word-size compare_exchange.
2024-03-07 20:55:25 +00:00
Jonathan Wakely
ddd347fca0 libstdc++: Update expiry times for leap seconds lists
The list in tzdb.cc isn't the only hardcoded list of leap seconds in the
library, there's the one defined inline in <chrono> (to avoid loading
the tzdb for the common case) and another in a testcase. This updates
them to note that there are no new leap seconds in 2024 either, until at
least 2024-12-28.

libstdc++-v3/ChangeLog:

	* include/std/chrono (__get_leap_second_info): Update expiry
	time for hardcoded list of leap seconds.
	* testsuite/std/time/tzdb/leap_seconds.cc: Update comment.
2024-03-07 20:55:25 +00:00
Jonathan Wakely
709d8474bc libstdc++: Replace unnecessary uses of built-ins in testsuite
I don't see why we should rely on __builtin_memset etc. in tests. We can
just include <cstring> and use the public API.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/deque/allocator/default_init.cc: Use
	std::memset instead of __builtin_memset.
	* testsuite/23_containers/forward_list/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/list/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/map/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/set/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/vector/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/allocator/default_init.cc:
	Likewise.
	* testsuite/29_atomics/atomic/compare_exchange_padding.cc:
	Likewise.
	* testsuite/util/atomic/wait_notify_util.h: Likewise.
2024-03-07 20:55:25 +00:00
Jonathan Wakely
24a2b5def0 libstdc++: Better diagnostics for std::format errors
This adds two new static_assert messages to the internals of
std::make_format_args to give better diagnostics for invalid format
args. Rather than just getting an error saying that basic_format_arg
cannot be constructed, we get more specific errors for the cases where
std::formatter isn't specialized for the type at all, and where it's
specialized but only meets the BasicFormatter requirements and so can
only format non-const arguments.

Also add a test for the existing static_assert when constructing a
format_string for non-formattable args.

libstdc++-v3/ChangeLog:

	* include/std/format (_Arg_store::_S_make_elt): Add two
	static_assert checks to give more user-friendly error messages.
	* testsuite/lib/prune.exp (libstdc++-dg-prune): Prune another
	form of "in requirements with" note.
	* testsuite/std/format/arguments/args_neg.cc: Check for
	user-friendly diagnostics for non-formattable types.
	* testsuite/std/format/string_neg.cc: Likewise.
2024-03-07 20:55:24 +00:00
GCC Administrator
264e3ad419 Daily bump. 2024-03-05 00:18:04 +00:00
Jonathan Wakely
0a545ac700 libstdc++: Add missing std::tuple constructor [PR114147]
I caused a regression with commit r10-908 by adding a constraint to the
non-explicit allocator-extended default constructor, but seemingly
forgot to add an explicit overload with the corresponding constraint.

libstdc++-v3/ChangeLog:

	PR libstdc++/114147
	* include/std/tuple (tuple::tuple(allocator_arg_t, const Alloc&)):
	Add missing overload of allocator-extended default constructor.
	(tuple<T1,T2>::tuple(allocator_arg_t, const Alloc&)): Likewise.
	* testsuite/20_util/tuple/cons/114147.cc: New test.
2024-03-04 20:24:58 +00:00
GCC Administrator
b05f474c8f Daily bump. 2024-03-01 00:16:41 +00:00
Jonathan Wakely
02ca9d3f0c libstdc++: Fix std::basic_format_arg::handle for BasicFormatters
std::basic_format_arg::handle is supposed to format its value as const
if that is valid, to reduce the number of instantiations of the
formatter's format function. I made a silly typo so that it checks
formattable_with<TD, Context> not formattable_with<const TD, Context>,
which breaks support for BasicFormatters i.e. ones that can only format
non-const types.

There's a static_assert in the handle constructor which is supposed to
improve diagnostics for trying to format a const argument with a
formatter that doesn't support it. That condition can't fail, because
the std::basic_format_arg constructor is already constrained to check
that the argument type is formattable. The static_assert can be removed.

libstdc++-v3/ChangeLog:

	* include/std/format (basic_format_arg::handle::__maybe_const_t):
	Fix condition to check if const type is formattable.
	(basic_format_arg::handle::handle(T&)): Remove redundant
	static_assert.
	* testsuite/std/format/formatter/basic.cc: New test.
2024-02-29 17:49:43 +00:00
Jonathan Wakely
f5cdda8acb libstdc++: Fix conditions for using memcmp in std::lexicographical_compare_three_way [PR113960]
The change in r11-2981-g2f983fa69005b6 meant that
std::lexicographical_compare_three_way started to use memcmp for
unsigned integers on big endian targets, but for that to be valid we
need the two value types to have the same size and we need to use that
size to compute the length passed to memcmp.

I already defined a __is_memcmp_ordered_with trait that does the right
checks, std::lexicographical_compare_three_way just needs to use it.

libstdc++-v3/ChangeLog:

	PR libstdc++/113960
	* include/bits/stl_algobase.h (__is_byte_iter): Replace with ...
	(__memcmp_ordered_with): New concept.
	(lexicographical_compare_three_way): Use __memcmp_ordered_with
	instead of __is_byte_iter. Use correct length for memcmp.
	* testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc:
	New test.
2024-02-29 17:49:43 +00:00
GCC Administrator
fd52355aa5 Daily bump. 2024-02-29 00:16:43 +00:00
Jonathan Wakely
80c386cb20 libstdc++: Fix noexcept on dtors in <experimental/scope> [PR114152]
The PR points out that the destructors all have incorrect
noexcept-specifiers.

libstdc++-v3/ChangeLog:

	PR libstdc++/114152
	* include/experimental/scope (scope_exit scope_fail): Make
	destructor unconditionally noexcept.
	(scope_sucess): Fix noexcept-specifier.
	* testsuite/experimental/scopeguard/114152.cc: New test.
2024-02-28 14:50:13 +00:00
Jonathan Wakely
06866bc368 libstdc++: Change some URLs in the manual to use https
libstdc++-v3/ChangeLog:

	* doc/xml/manual/appendix_contributing.xml: Change URLs to use
	https.
	* doc/html/manual/*: Regenerate.
2024-02-28 14:37:12 +00:00
Jonathan Wakely
7c7c937b5e libstdc++: Update outdated docs on contributing
We don't want a separate ChangeLog submission now.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/appendix_contributing.xml: Replace outdated
	info on ChangeLog entries.
	* doc/html/manual/appendix_contributing.html: Regenerate.
2024-02-28 14:32:38 +00:00
Jonathan Wakely
2d8cd712b1 libstdc++: Add more nodiscard uses in <vector>
Add [[nodiscard]] to vector::at and to comparison operators.

libstdc++-v3/ChangeLog:

	* include/bits/stl_bvector.h (vector<bool, A>::at): Add
	nodiscard.
	* include/bits/stl_vector.h (vector<T, A>::at): Likewise.
	(operator==, operator<=>, operator<, operator!=, operator>)
	(operator<=, operator>=): Likewise.
	* include/debug/vector (operator==, operator<=>, operator<)
	(operator!=, operator>, operator<=, operator>=): Likewise.
	* testsuite/23_containers/vector/nodiscard.cc: New test.
2024-02-28 11:27:46 +00:00
Jonathan Wakely
cf918498ab libstdc++: Consistently use noexcept, constexpr, nodiscard on bitmask ops
The bitwise operators for combining bitmask types such as std::launch
are not consistently annotated with noexcept, constexpr, and nodiscard.

This is the subject of LWG 3977, although the proposed resolution
doesn't work. We can make the changes in libstdc++ anyway though.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h (operator|, operator&): Add
	noexcept.
	* include/bits/fs_fwd.h (operator&, operator|, operator^)
	(operator~): Add nodiscard to overloads for copy_options, perms,
	perm_options, and directory_options.
	* include/bits/ios_base.h (operator&, operator|, operator^)
	(operator~): Add nodiscard and noexcept to overloads for
	_Ios_Fmtflags, _Ios_Openmode, and _Ios_Iostate.
	(operator|=, operator&=, operator^=): Add constexpr for C++14.
	* include/bits/regex_constants.h (operator&, operator|, operator^)
	(operator~): Add nodiscard and noexcept to overloads for
	syntax_option_type and match_flag_type.
	(operator|=, operator&=, operator^=): Add noexcept.
	* include/std/charconv (operator&, operator|, operator^)
	(operator~): Add nodiscard to overloads for chars_format.
	* include/std/future (operator&, operator|, operator^)
	(operator~): Add nodiscard for overloads for launch.
	(operator&=, operator|=, operator^=): Add constexpr for C++14.
	* include/experimental/bits/fs_fwd.h  (operator&, operator|)
	(operator^, operator~): Add nodiscard to overloads for
	copy_options, perms, and directory_options.
	* testsuite/27_io/ios_base/types/fmtflags/bitmask_operators.cc:
	Add dg-warning for nodiscard warnings.
	* testsuite/27_io/ios_base/types/iostate/bitmask_operators.cc:
	Likewise.
	* testsuite/27_io/ios_base/types/openmode/bitmask_operators.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/bitmask_types.cc:
	New test.
2024-02-28 11:27:46 +00:00
Jonathan Wakely
5c22de3fec libstdc++: Test error handling in std::print
The standard requires an exception if std::print fails to write to a
FILE*. When writing to a std::ostream, failure to format the arguments
doesn't affect the stream state, but failure to write to the streadm
sets badbit.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_ostream/print/1.cc: Check error
	handling.
	* testsuite/27_io/print/1.cc: Likewise.
2024-02-28 11:27:46 +00:00
Jonathan Wakely
4da67f63b9 libstdc++: Fix std::print for Cygwin
Cygwin should use std::fwrite, not WriteConsoleW. And the -lstdc++exp
library is only needed when running the tests on *-*-mingw*.

libstdc++-v3/ChangeLog:

	* include/std/ostream (vprint_unicode) [__CYGWIN__]: Use POSIX
	code path for Cygwin instead of Windows.
	* include/std/print (vprint_unicode) [__CYGWIN__]: Likewise.
	* testsuite/27_io/basic_ostream/print/1.cc: Only add -lstdc++exp
	for *-*-mingw* targets.
	* testsuite/27_io/print/1.cc: Likewise.
2024-02-28 11:27:46 +00:00
Jonathan Wakely
3c1e624a92 libstdc++: Include <bits/stl_iterator.h> in <bits/alloc_traits.h>
libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h: Include <bits/stl_iterator.h> for
	__make_move_if_noexcept_iterator.
2024-02-28 11:27:46 +00:00
Jonathan Wakely
d59175ef8a libstdc++: Add more [[nodiscard]] to <stacktrace>
libstdc++-v3/ChangeLog:

	* include/std/stacktrace: Add nodiscard attribute to all
	functions without side effects.
2024-02-28 11:27:45 +00:00
GCC Administrator
b4c88cc717 Daily bump. 2024-02-21 00:17:26 +00:00