Commit graph

14771 commits

Author SHA1 Message Date
GCC Administrator
08c5d26afa Daily bump. 2023-12-19 00:17:36 +00:00
Patrick Palka
4f54e65678 libstdc++: Make ranges::to closure objects SFINAE-friendly [PR112802]
This also happens to fix composition of these closure objects.

	PR libstdc++/112802
	PR libstdc++/113068

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::_To::operator()): Add constraints.
	(__detail::_To2::operator()): Likewise.
	* testsuite/std/ranges/conv/1.cc (test_sfinae): New test.
	(test_composition): New test.
2023-12-18 18:05:36 -05:00
GCC Administrator
7e6f0faa8b Daily bump. 2023-12-17 00:17:30 +00:00
Jonathan Wakely
1f7acbf042 libstdc++: Fix bootstrap on AIX due to fileno macro
On AIX fileno is a function-like macro, so enclose the name in
parentheses to ensure we use the real function.

libstdc++-v3/ChangeLog:

	* src/c++23/print.cc (__open_terminal(FILE*)): Avoid fileno
	macro.
2023-12-16 23:52:30 +00:00
H.J. Lu
308e9d693c libstdc++: Update some baseline_symbols.txt (x32)
* config/abi/post/x86_64-linux-gnu/x32/baseline_symbols.txt:
	Updated.
2023-12-16 10:43:27 -08:00
Ken Matsui
61d6dee992
libstdc++: Optimize std::remove_pointer compilation performance
This patch optimizes the compilation performance of std::remove_pointer
by dispatching to the new remove_pointer built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (remove_pointer): Use __remove_pointer
	built-in trait.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-12-16 08:59:40 -08:00
Ken Matsui
4b11101365
libstdc++: Optimize std::is_object compilation performance
This patch optimizes the compilation performance of std::is_object
by dispatching to the new __is_object built-in trait.

libstdc++-v3/ChangeLog:
	* include/std/type_traits (is_object): Use __is_object built-in
	trait.
	(is_object_v): Likewise.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-12-16 08:59:39 -08:00
Ken Matsui
cdd4387c5b
libstdc++: Optimize std::is_function compilation performance
This patch optimizes the compilation performance of std::is_function
by dispatching to the new __is_function built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_function): Use __is_function
	built-in trait.
	(is_function_v): Likewise. Optimize its implementation.  Move
	this under is_const_v as this depends on is_const_v.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-12-16 08:59:38 -08:00
Ken Matsui
e86cfcaef2
libstdc++: Optimize std::is_reference compilation performance
This patch optimizes the compilation performance of std::is_reference
by dispatching to the new __is_reference built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_reference): Use __is_reference
	built-in trait.
	(is_reference_v): Likewise.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-12-16 08:59:36 -08:00
Ken Matsui
fa454b8dd0
libstdc++: Optimize std::is_member_object_pointer compilation performance
This patch optimizes the compilation performance of
std::is_member_object_pointer by dispatching to the new
__is_member_object_pointer built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_member_object_pointer): Use
	__is_member_object_pointer built-in trait.
	(is_member_object_pointer_v): Likewise.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-12-16 08:59:35 -08:00
Ken Matsui
53f9d0cc07
libstdc++: Optimize std::is_member_function_pointer compilation performance
This patch optimizes the compilation performance of
std::is_member_function_pointer by dispatching to the new
__is_member_function_pointer built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_member_function_pointer): Use
	__is_member_function_pointer built-in trait.
	(is_member_function_pointer_v): Likewise.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-12-16 08:59:34 -08:00
Ken Matsui
d95e54347f
libstdc++: Optimize std::is_member_pointer compilation performance
This patch optimizes the compilation performance of std::is_member_pointer
by dispatching to the new __is_member_pointer built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_member_pointer): Use
	__is_member_pointer built-in trait.
	(is_member_pointer_v): Likewise.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-12-16 08:59:33 -08:00
Ken Matsui
4a235f8eb0
libstdc++: Optimize std::is_scoped_enum compilation performance
This patch optimizes the compilation performance of std::is_scoped_enum
by dispatching to the new __is_scoped_enum built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_scoped_enum): Use
	__is_scoped_enum built-in trait.
	(is_scoped_enum_v): Likewise.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-12-16 08:59:32 -08:00
Ken Matsui
8843cff6c9
libstdc++: Optimize std::is_bounded_array compilation performance
This patch optimizes the compilation performance of std::is_bounded_array
by dispatching to the new __is_bounded_array built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_bounded_array_v): Use
	__is_bounded_array built-in trait.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-12-16 08:59:31 -08:00
Ken Matsui
7fd9c349e4
libstdc++: Optimize std::is_array compilation performance
This patch optimizes the compilation performance of std::is_array
by dispatching to the new __is_array built-in trait.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_array): Use __is_array built-in
	trait.
	(is_array_v): Likewise.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-12-16 08:59:30 -08:00
GCC Administrator
ea54b390ae Daily bump. 2023-12-16 00:17:35 +00:00
Jonathan Wakely
1d8ac2a74f libstdc++: Fix std::print test case for Windows
libstdc++-v3/ChangeLog:

	* src/c++23/print.cc (__write_to_terminal) [_WIN32]: If handle
	does not refer to the console then just write to it using normal
	file I/O.
	* testsuite/27_io/print/2.cc (as_printed_to_terminal): Print
	error message on failure.
	(test_utf16_transcoding): Adjust for as_printed_to_terminal
	modifying its argument.
2023-12-15 13:20:49 +00:00
Jonathan Wakely
7d2e100058 libstdc++: Simplify std::vprint_unicode for non-Windows targets
Since we don't need to do anything special to print Unicode on
non-Windows targets, we might as well just use std::vprint_nonunicode to
implement std::vprint_unicode. Removing the duplicated code should
reduce code size in cases where those calls aren't inlined.

Also use an RAII type for the unused case where a non-Windows target
calls __open_terminal(streambuf*) and needs to fclose the result. This
makes the code futureproof in case we ever start using the
__write_terminal function for non-Windows targets.

libstdc++-v3/ChangeLog:

	* include/std/ostream (vprint_unicode) [_WIN32]: Use RAII guard.
	(vprint_unicode) [!_WIN32]: Just call vprint_nonunicode.
	* include/std/print (vprint_unicode) [!_WIN32]: Likewise.
2023-12-15 13:20:49 +00:00
Jonathan Wakely
8a5cac92e7 libstdc++: Do not add padding for std::print to std::ostream
Tim Song pointed out that although std::print behaves as a formatted
output function, it does "determine padding" using the stream's flags.

libstdc++-v3/ChangeLog:

	* include/std/ostream (vprint_nonunicode, vprint_unicode): Do
	not insert padding.
	* testsuite/27_io/basic_ostream/print/1.cc: Adjust expected
	behaviour.
2023-12-15 13:20:49 +00:00
GCC Administrator
f998335ac0 Daily bump. 2023-12-15 00:17:17 +00:00
Jonathan Wakely
fe54b57728 libstdc++: Implement C++23 <print> header [PR107760]
This adds the C++23 std::print functions, which use std::format to write
to a FILE stream or std::ostream (defaulting to stdout).

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

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

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

libstdc++-v3/ChangeLog:

	PR libstdc++/107760
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/version.def (__cpp_lib_print): Define.
	* include/bits/version.h: Regenerate.
	* include/std/format (__literal_encoding_is_utf8): New function.
	(_Seq_sink::view()): New member function.
	* include/std/ostream (vprintf_nonunicode, vprintf_unicode)
	(print, println): New functions.
	* include/std/print: New file.
	* src/c++23/Makefile.am: Add new source file.
	* src/c++23/Makefile.in: Regenerate.
	* src/c++23/print.cc: New file.
	* testsuite/27_io/basic_ostream/print/1.cc: New test.
	* testsuite/27_io/print/1.cc: New test.
	* testsuite/27_io/print/2.cc: New test.
2023-12-14 23:59:24 +00:00
Jonathan Wakely
29ad35a1db libstdc++: Fix filebuf::native_handle() for Windows
libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CHECK_FILEBUF_NATIVE_HANDLES): Add
	missing header to configure test. Check correct variable.
	* config/io/basic_file_stdio.cc (__basic_file<char>::native_handle):
	Fix typo.
	* configure: Regenerate.
	* testsuite/27_io/basic_filebuf/native_handle/char/1.cc: Do not
	call CloseHandle on the native handle.
	* testsuite/27_io/basic_filebuf/native_handle/wchar_t/1.cc:
	Likewise.
2023-12-14 23:59:21 +00:00
Jonathan Wakely
3fa0f9404b libstdc++: Tweaks for std::format fast path
Fix an incorrect call to _Sink::_M_reserve() which should have passed
the __n parameter. This was not actually a problem because it was in an
discarded statement, because only the _Seq_sink<basic_string<C>>
specialization was used.

Also add some branch prediction hints, explanatory comments, and debug
mode assertions to _Seq_sink.

libstdc++-v3/ChangeLog:

	* include/std/format (_Seq_sink): Fix missing argument in
	discarded statement. Add comments, likely/unlikely attributes
	and debug assertions as sanity checks.
2023-12-14 22:04:43 +00:00
Jonathan Wakely
0c773209fc libstdc++: Add dg-output to two tests
These tests are expected to run interactively, with the output checked
by eye. Nobody ever does that, but we can at least use dg-output to
check that the output is as expected.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/objects/char/2.cc: Use dg-output.
	* testsuite/27_io/objects/wchar_t/2.cc: Use dg-output.
2023-12-14 22:04:43 +00:00
Jonathan Wakely
2ef5200a6f libstdc++: Fix %S format of duration with floating-point rep
I got the order of arguments to std::format_to wrong. It was in a
discarded statement, for a case which wasn't being tested.

libstdc++-v3/ChangeLog:

	* include/bits/chrono_io.h (__formatter_chrono::_M_S): Fix order
	of arguments to std::format_to.
	* testsuite/20_util/duration/io.cc: Test subsecond duration with
	floating-point rep.
2023-12-14 22:04:42 +00:00
Jonathan Wakely
7d00a59229 libstdc++: Make __gnu_debug::vector usable in constant expressions [PR109536]
This makes constexpr std::vector (mostly) work in Debug Mode. All safe
iterator instrumentation and checking is disabled during constant
evaluation, because it requires mutex locks and calls to non-inline
functions defined in libstdc++.so. It should be OK to disable the safety
checks, because most UB should be detected during constant evaluation
anyway.

We could try to enable the full checking in constexpr, but it would mean
wrapping all the non-inline functions like _M_attach with an inline
_M_constexpr_attach that does the iterator housekeeping inline without
mutex locks when called for constant evaluation, and calls the
non-inline function at runtime. That could be done in future if we find
that we've lost safety or useful checking by disabling the safe
iterators.

There are a few test failures in C++20 mode, which I'm unable to
explain. The _Safe_iterator::operator++() member gives errors for using
non-constexpr functions during constant evaluation, even though those
functions are guarded by std::is_constant_evaluated() checks. The same
code works fine for C++23 and up.

libstdc++-v3/ChangeLog:

	PR libstdc++/109536
	* include/bits/c++config (__glibcxx_constexpr_assert): Remove
	macro.
	* include/bits/stl_algobase.h (__niter_base, __copy_move_a)
	(__copy_move_backward_a, __fill_a, __fill_n_a, __equal_aux)
	(__lexicographical_compare_aux): Add constexpr to overloads for
	debug mode iterators.
	* include/debug/helper_functions.h (__unsafe): Add constexpr.
	* include/debug/macros.h (_GLIBCXX_DEBUG_VERIFY_COND_AT): Remove
	macro, folding it into ...
	(_GLIBCXX_DEBUG_VERIFY_AT_F): ... here. Do not use
	__glibcxx_constexpr_assert.
	* include/debug/safe_base.h (_Safe_iterator_base): Add constexpr
	to some member functions. Omit attaching, detaching and checking
	operations during constant evaluation.
	* include/debug/safe_container.h (_Safe_container): Likewise.
	* include/debug/safe_iterator.h (_Safe_iterator): Likewise.
	* include/debug/safe_iterator.tcc (__niter_base, __copy_move_a)
	(__copy_move_backward_a, __fill_a, __fill_n_a, __equal_aux)
	(__lexicographical_compare_aux): Add constexpr.
	* include/debug/vector (_Safe_vector, vector): Add constexpr.
	Omit safe iterator operations during constant evaluation.
	* testsuite/23_containers/vector/bool/capacity/constexpr.cc:
	Remove dg-xfail-if for debug mode.
	* testsuite/23_containers/vector/bool/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/vector/bool/cons/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/element_access/1.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/element_access/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/modifiers/assign/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/modifiers/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/modifiers/swap/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/capacity/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/vector/cons/constexpr.cc: Likewise.
	* testsuite/23_containers/vector/data_access/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/element_access/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/modifiers/assign/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/modifiers/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/modifiers/swap/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/cons/destructible_debug_neg.cc:
	Adjust dg-error line number.
2023-12-14 16:07:48 +00:00
GCC Administrator
e8018ccff9 Daily bump. 2023-12-14 00:18:00 +00:00
Jonathan Wakely
ad537ccd52 libstdc++: Fix regression in std::format output of %Y for negative years
The change in r14-6468-ga01462ae8bafa8 was only supposed to apply to %C
formats, not %Y.

libstdc++-v3/ChangeLog:

	* include/bits/chrono_io.h (__formatter_chrono::_M_C_y_Y): Do
	not round century down for %Y formats.
2023-12-13 12:30:14 +00:00
GCC Administrator
8a5d6ce0e8 Daily bump. 2023-12-13 00:17:49 +00:00
Jonathan Wakely
52de6aa1a8 libstdc++: Fix std::format("{}", 'c')
When I added a fast path for std::format("{}", x) in
r14-5587-g41a5ea4cab2c59 I forgot to handle char separately from other
integral types. That caused std::format("{}", 'c') to return "99"
instead of "c".

libstdc++-v3/ChangeLog:

	* include/std/format (__do_vformat_to): Handle char separately
	from other integral types.
	* testsuite/std/format/functions/format.cc: Check for expected
	output for char and bool arguments.
	* testsuite/std/format/string.cc: Check that 0 filling is
	rejected for character and string formats.
2023-12-12 22:33:32 +00:00
Jonathan Wakely
a01462ae8b libstdc++: Fix std::format output of %C for negative years
During discussion of LWG 4022 I noticed that we do not correctly
implement floored division for the century. We were just truncating
towards zero, rather than applying the floor function. For negative
values that rounds the wrong way.

libstdc++-v3/ChangeLog:

	* include/bits/chrono_io.h (__formatter_chrono::_M_C_y_Y): Fix
	rounding for negative centuries.
	* testsuite/std/time/year/io.cc: Check %C for negative years.
2023-12-12 22:33:32 +00:00
Jonathan Wakely
988dd6384c libstdc++: Remove redundant -std flags from Makefile
In r14-4060-gc4baeaecbbf7d0 I moved some files from src/c++98 to
src/c++11 but I didn't remove the redundant -std=gnu++11 flags for those
files. The flags aren't needed now, because AM_CXXFLAGS for that
directory already uses -std=gnu++11. This removes them.

libstdc++-v3/ChangeLog:

	* src/c++11/Makefile.am: Remove redundant -std=gnu++11 flags.
	* src/c++11/Makefile.in: Regenerate.
2023-12-12 22:32:35 +00:00
GCC Administrator
fbfe43daec Daily bump. 2023-12-10 00:16:47 +00:00
Jonathan Wakely
cdf45e00a9 libstdc++: Fix value of __cpp_lib_format macro [PR111826]
As noted in the PR, we support both features required for the 202110L
value, so we should define it with that value.

libstdc++-v3/ChangeLog:

	PR libstdc++/111826
	* include/bits/version.def (format): Update value.
	* include/bits/version.h: Regenerate.
	* testsuite/std/format/functions/format.cc:
2023-12-09 11:51:41 +00:00
Jonathan Wakely
a314edee24 libstdc++: Fix resolution of LWG 4016 for std::ranges::to [PR112876]
What I implemented in r14-6199-g45630fbcf7875b does not match what I
proposed for LWG 4016, and it imposes additional, unwanted requirements
on the emplace and insert member functions of the container being
populated.

libstdc++-v3/ChangeLog:

	PR libstdc++/112876
	* include/std/ranges (ranges::to): Do not try to use an iterator
	returned by the container's emplace or insert member functions.
	* testsuite/std/ranges/conv/1.cc (Cont4::emplace, Cont4::insert):
	Use the iterator parameter. Do not return an iterator.
2023-12-09 11:51:41 +00:00
GCC Administrator
08f89e5e7f Daily bump. 2023-12-08 00:17:33 +00:00
Patrick Palka
0832cf42a6 libstdc++: Simplify ranges::to closure objects
We can use the existing _Partial range adaptor closure object for
ranges::to instead of essentially reimplementing it.

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::_ToClosure): Replace with ...
	(__detail::_To): ... this.
	(__detail::_ToClosure2): Replace with ...
	(__detail::To2): ... this.
	(to): Simplify using the existing _Partial range adaptor
	closure object.
2023-12-07 16:36:23 -05:00
Jonathan Wakely
cab0083dc7 libstdc++: Fix misleading typedef name in <format>
This local typedef for uintptr_t was accidentally named uint64_t,
probably from a careless code completion shortcut. We don't need the
typedef at all since it's only used once. Just use __UINTPTR_TYPE__
directly instead.

libstdc++-v3/ChangeLog:

	* include/std/format (_Iter_sink<charT, contiguous_iterator>):
	Remove uint64_t local type.
2023-12-07 20:56:34 +00:00
Jonathan Wakely
2f512f6fcd libstdc++: Use <cstdint> instead of <stdint.h> in <bits/atomic_wait.h>
In r14-5922-g6c8f2d3a08bc01 I added <stdint.h> to <bits/atomic_wait.h>,
so that uintptr_t is declared if that header is compiled as a header
unit. I used <stdint.h> because that's what <atomic> already includes,
so it seemed simpler to be consistent. However, this means that name
lookup for uintptr_t in <bits/atomic_wait.h> depends on whether
<cstdint> has been included by another header first. Whether name lookup
finds std::uintptr_t or ::uintptr_t will depend on include order. This
causes problems when compiling modules with Clang:

bits/atomic_wait.h:251:7: error: 'std::__detail::__waiter_pool_base' has different definitions in different modules; first difference is defined here found method '_S_for' with body
      _S_for(const void* __addr) noexcept
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bits/atomic_wait.h:251:7: note: but in 'tm.<global>' found method '_S_for' with different body
      _S_for(const void* __addr) noexcept
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

By including <cstdint> we would ensure that name lookup always finds the
name in namespace std. Alternatively, we can stop including <stdint.h>
for those types, so that we don't declare the entire contents of
<stdint.h> when we only need a couple of types from it. This patch does
the former, which is appropriate for backporting.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_wait.h: Include <cstdint> instead of
	<stdint.h>.
2023-12-07 20:54:11 +00:00
Jonathan Wakely
1395c573c5 libstdc++: Fix recent changes to __glibcxx_assert [PR112882]
The changes in r14-6198-g5e8a30d8b8f4d7 were broken, as I used
_GLIBCXX17_CONSTEXPR for the 'if _GLIBCXX17_CONSTEXPR (true)' condition,
forgetting that it would also be used for the is_constant_evaluated()
check. Using 'if constexpr (std::is_constant_evaluated())' is a bug.

Additionally, relying on __glibcxx_assert_fail to give a "not a constant
expression" error is a problem because at -O0 an undefined reference to
__glibcxx_assert_fail is present in the compiled code. This means you
can't use libstdc++ headers without also linking to libstdc++ for the
symbol definition.

This fix rewrites the __glibcxx_assert macro again. This still avoids
doing the duplicate checks, once for constexpr and once at runtime (if
_GLIBCXX_ASSERTIONS is defined). When _GLIBCXX_ASSERTIONS is defined we
still rely on __glibcxx_assert_fail to give a "not a constant
expression" error during constant evaluation (because when assertions
are defined it's not a problem to emit a reference to the symbol). But
when that macro is not defined, we use a new inline (but not constexpr)
overload of __glibcxx_assert_fail to cause compilation to fail. That
inline function doesn't cause an undefined reference to a symbol in the
library (and will be optimized away anyway).

We can also add always_inline to the __is_constant_evaluated function,
although this doesn't actually matter for -O0 and it's always inlined
with any optimization enabled.

libstdc++-v3/ChangeLog:

	PR libstdc++/112882
	* include/bits/c++config (__is_constant_evaluated): Add
	always_inline attribute.
	(_GLIBCXX_DO_ASSERT): Remove macro.
	(__glibcxx_assert): Define separately for assertions-enabled and
	constexpr-only cases.
2023-12-07 20:54:11 +00:00
Alexandre Oliva
3d0f3382fa libsupc++: try cxa_thread_atexit_impl at runtime
g++.dg/tls/thread_local-order2.C fails when the toolchain is built for
a platform that lacks __cxa_thread_atexit_impl, even if the program is
built and run using that toolchain on a (later) platform that offers
__cxa_thread_atexit_impl.

This patch adds runtime testing for __cxa_thread_atexit_impl on select
platforms (GNU variants, for starters) that support weak symbols.


for  libstdc++-v3/ChangeLog

	PR libstdc++/112858
	* config/os/gnu-linux/os_defines.h
	(_GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL): Define.
	* libsupc++/atexit_thread.cc [__GXX_WEAK__ &&
	_GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL]
	(__cxa_thread_atexit): Add dynamic detection of
	__cxa_thread_atexit_impl.
2023-12-07 00:38:14 -03:00
GCC Administrator
ae9e48e5c0 Daily bump. 2023-12-07 00:17:06 +00:00
Jason Merrill
c1e54c82a9 c++: partial ordering of object parameter [PR53499]
Looks like we implemented option 1 (skip the object parameter) for CWG532
before the issue was resolved, and never updated to the final resolution of
option 2 (model it as a reference).  More recently CWG2445 extended this
handling to static member functions; I think that's wrong, and have
opened CWG2834 to address that and how explicit object member functions
interact with it.

The FIXME comments are to guide how the explicit object member function
support should change the uses of DECL_NONSTATIC_MEMBER_FUNCTION_P.

The library testsuite changes are to make partial ordering work again
between the generic operator- in the testcase and
_Pointer_adapter::operator-.

	DR 532
	PR c++/53499

gcc/cp/ChangeLog:

	* pt.cc (more_specialized_fn): Fix object parameter handling.

gcc/testsuite/ChangeLog:

	* g++.dg/template/partial-order4.C: New test.
	* g++.dg/template/spec26.C: Adjust for CWG532.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/vector/ext_pointer/types/1.cc
	* testsuite/23_containers/vector/ext_pointer/types/2.cc
	(N::operator-): Make less specialized.
2023-12-06 09:02:01 -05:00
Alexandre Oliva
953a9302d1 Revert "libsupc++: try cxa_thread_atexit_impl at runtime"
This reverts commit f4dd941684.
2023-12-05 22:16:37 -03:00
GCC Administrator
3dd09cd9e1 Daily bump. 2023-12-06 00:17:50 +00:00
Jonathan Wakely
08448dc146 libstdc++: Add workaround to std::ranges::subrange [PR111948]
libstdc++-v3/ChangeLog:

	PR libstdc++/111948
	* include/bits/ranges_util.h (subrange): Add constructor to
	_Size to aoid setting member in constructor.
	* testsuite/std/ranges/subrange/111948.cc: New test.
2023-12-05 23:34:12 +00:00
Jonathan Wakely
45630fbcf7 libstdc++: Implement LWG 4016 for std::ranges::to
This implements the proposed resolution of LWG 4016, so that
std::ranges::to does not use std::back_inserter and std::inserter.
Instead it inserts at the back of the container directly, using
the first supported one of emplace_back, push_back, emplace, and insert.

Using emplace avoids creating a temporary that has to be moved into the
container, for cases where the source range and the destination
container do not have the same value type.

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::__container_insertable): Remove.
	(__detail::__container_inserter): Remove.
	(ranges::to): Use emplace_back or emplace, as per LWG 4016.
	* testsuite/std/ranges/conv/1.cc (Cont4, test_2_1_4): Check for
	use of emplace_back and emplace.
2023-12-05 23:34:12 +00:00
Jonathan Wakely
5e8a30d8b8 libstdc++: Redefine __glibcxx_assert to work in C++23 constexpr
The changes in r14-5979 to support unknown references in constant
expressions caused some test regressions. The way that __glibcxx_assert
is defined for constant evaluation no longer works when
_GLIBCXX_ASSERTIONS is defined.

This change simplifies __glibcxx_assert so that there is only one check,
rather than a constexpr one and a conditionally-enabled runtime one. The
constexpr one does not need to use __builtin_unreachable to cause a
compilation failure, because __glibcxx_assert_fail is not usable in
constant expressions, so that will cause a failure too.

As well as fixing the regressions, this makes the code for the
assertions shorter and simpler, so should be quicker to compile, and
might inline better too.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (__glibcxx_assert_fail): Declare even
	when assertions are not enabled.
	(__glibcxx_constexpr_assert): Remove macro.
	(__glibcxx_assert_impl): Remove macro.
	(_GLIBCXX_ASSERT_FAIL): New macro.
	(_GLIBCXX_DO_ASSERT): New macro.
	(__glibcxx_assert): Simplify to a single definition that works
	at runtime and during constant evaluation.
	* testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc:
	Adjust expected errors.
	* testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/debug.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/debug.cc:
	Likewise.
	* testsuite/23_containers/span/back_neg.cc: Likewise.
	* testsuite/23_containers/span/front_neg.cc: Likewise.
	* testsuite/23_containers/span/index_op_neg.cc: Likewise.
	* testsuite/26_numerics/lcm/105844.cc: Likewise.
2023-12-05 23:33:22 +00:00
Jonathan Wakely
3cd73543a1 libstdc++: Disable std::formatter::set_debug_format [PR112832]
All set_debug_format member functions should be guarded by the
__cpp_lib_formatting_ranges macro (which is not defined yet).

libstdc++-v3/ChangeLog:

	PR libstdc++/112832
	* include/std/format (formatter::set_debug_format): Ensure this
	member is defined conditionally for all specializations.
	* testsuite/std/format/formatter/112832.cc: New test.
2023-12-05 16:40:43 +00:00
Will Hawkins
9fff752695 libstdc++: Add test for LWG Issue 3897
Add a test to verify that the implementation of inout_ptr is not
vulnerable to LWG Issue 3897.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/smartptr.adapt/inout_ptr/2.cc: Add check
	for LWG Issue 3897.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
2023-12-05 16:40:43 +00:00