[committed v2] libstdc++: Move std::basic_ostream to new internal header [PR99995]

2025-01-16 Thread Jonathan Wakely
This adds so that other headers don't need to include all of , which pulls in all of since C++23 (for the std::print and std::println overloads in ). This new header allows the constrained operator<< in to be defined without all of std::format being compiled. We could also replace with in all

[PATCH] libstdc++: Handle exceptions in std::ostream::sentry destructor

2025-01-16 Thread Jonathan Wakely
Because basic_ostream::sentry::~sentry is implicitly noexcept, we can't let any exceptions escape from it, or the program would terminate. If the streambuf's sync() function throws, or if it returns an error and setting badbit in the stream state throws, then the program would terminate. LWG 835 i

[wwwdocs, pushed] Document dependency changes for libstdc++ header

2025-01-16 Thread Jonathan Wakely
Pushed to wwwdocs. --- htdocs/gcc-15/porting_to.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/gcc-15/porting_to.html b/htdocs/gcc-15/porting_to.html index 2bc0d4e5..b9b2efc7 100644 --- a/htdocs/gcc-15/porting_to.html +++ b/htdocs/gcc-15/porting_to.html @@ -153,6 +153,9 @@ may

[wwwdocs, pushed] Document libstdc++ headers that are deprecated in GCC 15

2025-01-16 Thread Jonathan Wakely
Pushed to wwwdocs. --- htdocs/gcc-15/porting_to.html | 11 +++ 1 file changed, 11 insertions(+) diff --git a/htdocs/gcc-15/porting_to.html b/htdocs/gcc-15/porting_to.html index c446e309..2bc0d4e5 100644 --- a/htdocs/gcc-15/porting_to.html +++ b/htdocs/gcc-15/porting_to.html @@ -155,6 +15

Re: [committed] libstdc++: Implement LWG 2937 for std::filesystem::equivalent [PR118158]

2025-01-16 Thread Jonathan Wakely
On Thu, 16 Jan 2025 at 09:50, Jonathan Wakely wrote: > > Do not report an error for (is_other(s1) && is_other(s2)) as the > standard originally said, nor for (is_other(s1) || is_other(s2)) as > libstdc++ was doing. We can compare inode numbers for special files and > s

[committed] libstdc++: Implement LWG 2937 for std::filesystem::equivalent [PR118158]

2025-01-16 Thread Jonathan Wakely
Do not report an error for (is_other(s1) && is_other(s2)) as the standard originally said, nor for (is_other(s1) || is_other(s2)) as libstdc++ was doing. We can compare inode numbers for special files and so give sensible answers. libstdc++-v3/ChangeLog: PR libstdc++/118158 * src/

[committed] libstdc++: Check feature test macro for associative container node extraction

2025-01-16 Thread Jonathan Wakely
Replace some `__cplusplus > 201402L` preprocessor checks with more expressive checks for the appropriate feature test macro. libstdc++-v3/ChangeLog: * include/bits/stl_map.h: Check __glibcxx_node_extract instead of __cplusplus. * include/bits/stl_multimap.h: Likewise.

[committed] libstdc++: Fix use of internal feature test macro in test

2025-01-15 Thread Jonathan Wakely
This test should use __cpp_lib_ios_noreplace rather than the internal __glibcxx_ios_noreplace macro. libstdc++-v3/ChangeLog: * testsuite/27_io/ios_base/types/openmode/case_label.cc: Use standard feature test macro not internal one. --- Tested x86_64-linux. Pushed to trunk. .../

[committed] libstdc++: Fix fancy pointer test for std::set

2025-01-15 Thread Jonathan Wakely
The alloc_ptr.cc test for std::set tries to use C++17 features unconditionally, and tries to use the C++23 range members which haven't been implemented for std::set yet. Some of the range checks are left in place but commented out, so they can be added after the ranges members are implemented. Oth

[committed] libstdc++: Fix reversed args in unreachable assumption [PR109849]

2025-01-15 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: PR libstdc++/109849 * include/bits/vector.tcc (vector::_M_range_insert): Fix reversed args in length calculation. --- Tested x86_64-linux, pushed to trunk. Backport to gcc-14 to follow after testing. libstdc++-v3/include/bits/vector.tcc | 2 +- 1

Re: [wwwdocs] Document that gcc-8 changed the default to -std=gnu17

2025-01-15 Thread Jonathan Wakely
On Mon, 23 Dec 2024 at 01:56, Gerald Pfeifer wrote: > > On Wed, 9 Oct 2024, Jonathan Wakely wrote: > > How about this? > > > > +C > > + > > +New options -std=c17, to select support for the 2018 > > +edition of the ISO C standard, and -std=g

[committed] libstdc++: Fix comments in test that reference wrong subclause of C++11

2025-01-15 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * testsuite/28_regex/traits/char/transform_primary.cc: Fix subclause numbering in references to the standard. --- Pushed to trunk. .../testsuite/28_regex/traits/char/transform_primary.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) dif

Re: [libstdc++] Optimize string constructors

2025-01-15 Thread Jonathan Wakely
On Fri, 13 Dec 2024 at 14:01, Jan Hubicka wrote: > > Hi, > this patch improves code generation on string constructors. We currently have > _M_construct which takes as a parameter two iterators (begin/end pointers to > other string) and produces new string. This patch adds special case of > const

Re: [PATCH] libstdc++: Use string::push_back instead of string::operator+=

2025-01-15 Thread Jonathan Wakely
On Mon, 30 Dec 2024 at 02:37, Aditya K wrote: > > From db5036e40ed7ac43b66ca74c44ec8d0bdc934b07 Mon Sep 17 00:00:00 2001 > From: AdityaK <1108430...@users.noreply.github.com> > Date: Sun, 29 Dec 2024 18:14:29 -0800 > Subject: [PATCH] libstdc++: Use string::push_back instead of > string::operator+

Re: [PATCH] testsuite: libstdc++: Use effective-target libatomic

2025-01-13 Thread Jonathan Wakely
On Mon, 13 Jan 2025 at 11:12, Thomas Schwinge wrote: > > Hi! > > On 2025-01-13T11:04:50+0000, Jonathan Wakely wrote: > > On Mon, 13 Jan 2025 at 11:03, Thomas Schwinge > > wrote: > >> On 2025-01-12T08:38:05+0100, Torbjorn SVENSSON > >> wrote: > &g

Re: [PATCH] testsuite: libstdc++: Use effective-target libatomic

2025-01-13 Thread Jonathan Wakely
On Mon, 13 Jan 2025 at 11:03, Thomas Schwinge wrote: > > Hi! > > On 2025-01-12T08:38:05+0100, Torbjorn SVENSSON > wrote: > > On 2025-01-12 01:05, Jonathan Wakely wrote: > >> On Mon, 23 Dec 2024, 19:05 Torbjörn SVENSSON, > >> mailto:torbjorn.svens...@fos

Re: [PATCH] testsuite: libstdc++: Use effective-target libatomic

2025-01-11 Thread Jonathan Wakely
On Mon, 23 Dec 2024, 19:05 Torbjörn SVENSSON, wrote: > Ok for trunk and releases/gcc-14? > OK > -- > > Test assumes libatomic.a is always available, but for some embedded > targets, there is no libatomic.a and the test thus fail. > > libstdc++/ChangeLog: > > * 29_atomics/atomic_float/

Re: [PATCH] testsuite: The expect framework might introduce CR in output

2025-01-11 Thread Jonathan Wakely
On Sat, 11 Jan 2025, 19:14 Torbjorn SVENSSON, wrote: > > > On 2025-01-11 20:05, Jonathan Wakely wrote: > > > > > > On Sat, 11 Jan 2025, 18:31 Torbjörn SVENSSON, > > mailto:torbjorn.svens...@foss.st.com>> > > wrote: > > > > Ok for trun

Re: [PATCH] testsuite: The expect framework might introduce CR in output

2025-01-11 Thread Jonathan Wakely
On Sat, 11 Jan 2025, 18:31 Torbjörn SVENSSON, wrote: > Ok for trunk and releases/gcc-14? > OK, thanks > -- > > When running tests using the "sim" config, the command is launched in > non-readonly mode and the text retrieved from the expect command will > then replace all LF with CRLF. (The pr

[PATCH 08/10] libstdc++: Rename __atomic_compare to __atomic_eq

2025-01-10 Thread Jonathan Wakely
This is an equality comparison rather than a three-way comparison like memcmp and <=>, so name it more precisely. libstdc++-v3/ChangeLog: * include/bits/atomic_timed_wait.h (__atomic_wait_address_until_v): Replace __atomic_compare with __atomic_eq. (__atomic_wait_a

[PATCH 09/10] libstdc++: Use safe integer comparisons in std::latch [PR98749]

2025-01-10 Thread Jonathan Wakely
Also add missing precondition check to constructor and fix existing check in count_down which was duplicated by mistake. libstdc++-v3/ChangeLog: PR libstdc++/98749 * include/std/latch (latch::max()): Use std::cmp_less to handle the case where __platform_wait_t is wider tha

[PATCH 05/10] libstdc++: Fix race condition in new atomic notify code

2025-01-10 Thread Jonathan Wakely
When using a proxy object for atomic waiting and notifying operations, we need to ensure that the _M_ver value is always incremented by a notifying operation, even if we return early without doing the futex wake syscall. Otherwise we get missed wake-ups because the notifying thread doesn't modify t

[PATCH 10/10] libstdc++: Optimise std::latch::arrive_and_wait

2025-01-10 Thread Jonathan Wakely
We don't need to wait if we know the counter has reached zero. libstdc++-v3/ChangeLog: * include/std/latch (latch::arrive_and_wait): Optimise. --- This one's commented out for now, but sending for review anyway. libstdc++-v3/include/std/latch | 12 1 file changed, 12 inser

[PATCH 06/10] libstdc++: Simplify futex wrapper functions for atomic wait/notify

2025-01-10 Thread Jonathan Wakely
Making these non-templates will allow them to be moved into the library at some point. libstdc++-v3/ChangeLog: * include/bits/atomic_wait.h (__platform_wait): Change function template to a normal function. The parameter is always __platform_wait_t* which is just int* for t

[PATCH 03/10] libstdc++: Whitespace fixes in atomic wait/notify code

2025-01-10 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * include/bits/atomic_timed_wait.h: Whitespace fixes. * include/bits/atomic_wait.h: Likewise. --- libstdc++-v3/include/bits/atomic_timed_wait.h | 198 +- libstdc++-v3/include/bits/atomic_wait.h | 8 +- 2 files changed, 100 insertions

[PATCH 07/10] libstdc++: Remove reinterpret_cast uses in atomic wait/notify

2025-01-10 Thread Jonathan Wakely
We can pass around void* instead of casting incompatible pointers to __platform_wait_t*, and then only static_cast to __platform_wait_t* when we know that's valid. libstdc++-v3/ChangeLog: * include/bits/atomic_timed_wait.h (__atomic_wait_address_until): Remove reinterpret_cast and

[PATCH 02/10] libstdc++: Pass __wait_args to internal API by const pointer

2025-01-10 Thread Jonathan Wakely
From: Thomas Rodgers This change splits the __wait_args data members to a new struct __wait_args_base and then passes that type by const pointer to the low level implementation functions. libstdc++-v3/ChangeLog: * include/bits/atomic_timed_wait.h (__spin_until_impl): Accept __wa

[PATCH 00/10] C++20 atomic wait/notify ABI stabilization

2025-01-10 Thread Jonathan Wakely
From: Jonathan Wakely This series complete Tom's work to refactor the C++20 atomic wait/notify code. The goal is to make the implementation ready for some pieces to be moved into libstdc++.so instead of defining everything inline in the headers. Also available for review at

[PATCH 01/10] libstdc++: Atomic wait/notify ABI stabilization

2025-01-10 Thread Jonathan Wakely
From: Thomas Rodgers This represents a major refactoring of the previous atomic::wait and atomic::notify implementation detail. The aim of this change is to simplify the implementation details and position the resulting implementation so that much of the current header-only detail can be moved in

[PATCH 04/10] libstdc++: Various fixes for atomic wait/notify code

2025-01-10 Thread Jonathan Wakely
Remove the unnecessary __wait_args_base base class, which seems to serve no purpose. Everywhere it's used we actually want __wait_args instead. The code using the __wait_flags bitmask type is broken, because the __spin_only constant includes the __do_spin element. This means that testing (__args &

[committed] libstdc++: Fix unused parameter warnings in

2025-01-10 Thread Jonathan Wakely
This fixes warnings like the following during bootstrap: sparc-sun-solaris2.11/libstdc++-v3/include/bits/atomic_futex.h:324:53: warning: unused parameter ‘__mo’ [-Wunused-parameter] 324 | _M_load_when_equal(unsigned __val, memory_order __mo) |~~

[PATCH] libstdc++: Create new base class of std::barrier for non-dependent code

2025-01-10 Thread Jonathan Wakely
This moves all non-dependent state and logic for std::barrier into a new non-template base class, to avoid template bloat. This would permit moving the _M_arrive function into the library instead of the header. libstdc++-v3/ChangeLog: * include/std/barrier (__tree_barrier_base): New clas

Re: libstdc++: Optimize std::vector

2025-01-10 Thread Jonathan Wakely
On Fri, 10 Jan 2025 at 14:51, Jonathan Wakely wrote: > > On Sun, 8 Dec 2024 at 15:36, Jan Hubicka wrote: > > > > Hi, > > std::vector has independent implementation for bool which has its won > > size/capacity functions. I updated them to add __builtin_unreachabl

Re: libstdc++: Optimize std::vector

2025-01-10 Thread Jonathan Wakely
On Sun, 8 Dec 2024 at 15:36, Jan Hubicka wrote: > > Hi, > std::vector has independent implementation for bool which has its won > size/capacity functions. I updated them to add __builtin_unreachable to > announce that size is never more than max_size. However while testing the > code > I notice

Re: [libstdc++] Optimize std::vector::operator[]

2025-01-10 Thread Jonathan Wakely
On Fri, 27 Dec 2024 at 20:13, Jan Hubicka wrote: > > Hi, > the following testcase: > > bool f(const std::vector& v, std::size_t x) { > return v[x]; > } > > is compiled as: > > f(std::vector > const&, unsigned long): > testq %rsi, %rsi > leaq63(%rsi), %rax > mo

Re: [PATCH][libstdc++]: backport inline keyword on std::find

2025-01-10 Thread Jonathan Wakely
On Fri, 10 Jan 2025 at 14:32, Tamar Christina wrote: > > Hi All, > > This is a backport version of the same patch as > https://gcc.gnu.org/pipermail/gcc-patches/2024-December/671618.html > > for the release branches. I'd like to backport this to GCC 14,13 and 12 where > the first regression showe

[PATCH] libstdc++: Fix std::barrier for constant initialization [PR118395]

2025-01-10 Thread Jonathan Wakely
The std::barrier constructor should be constexpr, which means we need to defer the dynamic allocation if the constructor is called during constant-initialization. We can defer it to the first call to barrier::arrive, using compare-and-swap on an atomic (instead of the unique_ptr currently used). A

[committed] libstdc++: Add always_inline to casting/forwarding functions in bits/move.h

2025-01-08 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * include/bits/move.h (__addressof, forward, forward_like, move) (move_if_noexcept, addressof): Add always_inline attribute. Replace _GLIBCXX_NODISCARD with [[__nodiscard__]]. --- Tested x86_64-linux. Pushed to trunk. libstdc++-v3/include/bits/mov

Re: [PATCH] libstdc++: Avoid redundant assertions in std::span constructors

2025-01-08 Thread Jonathan Wakely
On Thu, 12 Dec 2024 at 00:05, Jonathan Wakely wrote: > > Any std::span constructor with a runtime length has a precondition > that the length is equal to N (except when N == std::dynamic_extent). > > Currently every constructor with a runtime length does: > >

[committed] libstdc++: Adjust indentation of new std::span constructor

2025-01-08 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * include/std/span: Fix indentation. --- Tested x86_64-linux. Pushed to trunk. libstdc++-v3/include/std/span | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span index 4b40

[committed] libstdc++: Make GDB skip over some library functions [PR118260]

2025-01-08 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: PR libstdc++/118260 * python/hook.in: Run 'skip' commands for some simple accessor functions. --- Tested x86_64-linux. Pushed to trunk. libstdc++-v3/python/hook.in | 5 + 1 file changed, 5 insertions(+) diff --git a/libstdc++-v3/python/hook.i

[committed] libstdc++: Use preprocessor conditions in std module [PR118177]

2025-01-08 Thread Jonathan Wakely
The std-clib.cc module definition file assumes that all names are available unconditionally, but that's not true for all targets. Use the same preprocessor conditions as are present in the headers. A similar change is needed in std.cc.in for the features that depend on the SSO std::string, guard

Re: [PATCH] libstdc++: Handle errors from strxfrm in std::collate::transform [PR85824]

2025-01-08 Thread Jonathan Wakely
On Wed, 18 Dec 2024 at 21:19, Jonathan Wakely wrote: > > std::regex builds a cache of equivalence classes by calling > std::regex_traits::transform_primary(c) for every char, which then > calls std::collate::transform which calls strxfrm. On several > targets strxfrm fail

Re: [PATCH] libstdc++: Fix std::deque::emplace calling wrong _M_insert_aux [PR90389]

2025-01-08 Thread Jonathan Wakely
On Wed, 18 Dec 2024 at 00:40, Jonathan Wakely wrote: > > We have several overloads of std::deque::_M_insert_aux, one of which is > variadic and called by std::deque::emplace. With a suitable set of > arguments to emplace, it's possible for one of the non-variadic > _M_insert

Re: [PATCH] libstdc++: Fix future.wait_until when given a negative time_point

2025-01-08 Thread Jonathan Wakely
On Wed, 18 Dec 2024 at 00:35, Jonathan Wakely wrote: > > On Tue, 17 Dec 2024 at 19:38, Jonathan Wakely wrote: > > > > On Wed, 31 Jul 2024 at 22:39, Jonathan Wakely wrote: > > > > > > On Wed, 24 Jul 2024 at 14:14, William Tsai > > > wrote: > >

[committed] libstdc++: Fix incorrect DocBook element in manual

2025-01-08 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * doc/xml/manual/evolution.xml: Replace invalid elements with . * doc/html/*: Regenerate. --- Pushed to trunk, backports to follow. libstdc++-v3/doc/html/index.html | 4 ++-- libstdc++-v3/doc/html/manual/api.html | 4 ++-- libstdc++-

[committed] libstdc++: Add Doxygen docs for std::forward_like

2025-01-08 Thread Jonathan Wakely
Also add "@since C++11" to std::move, std::forward etc. libstdc++-v3/ChangeLog: * include/bits/move.h (forward, move, move_if_noexcept, addressof): Add @since to Doxygen comments. (forward_like): Add Doxygen comment. --- Tested x86_64-linux. Pushed to trunk. libstdc++-v

Re: [PATCH] libstdc++: add a constexpr macro for C++26

2025-01-08 Thread Jonathan Wakely
On Wed, 8 Jan 2025 at 11:00, Jakub Jelinek wrote: > > On Wed, Jan 08, 2025 at 11:57:32AM +0100, Giuseppe D'Angelo wrote: > > On 08/01/2025 11:49, Jakub Jelinek wrote: > > > > +#ifndef _GLIBCXX26_CONSTEXPR > > > > +# if __cplusplus >= 202303L > > > Shouldn't that be 202400L instead? I mean that is

Re: [PATCH] libstdc++: add missing to_underlying to module std [PR106852]

2025-01-07 Thread Jonathan Wakely
On Sat, 4 Jan 2025 at 20:06, Nicolas Werner wrote: > > std::to_underlying was missing from the std module introduced in > 7db55c0ba1baaf0e323ef7f9ef8c9cda077d40e9. This patch adds the missing > export for this utility. > > There might be more exports missing, but this is the one I found when > try

Re: [pushed] libstdc++: Delete leftover from Profile Mode removal

2024-12-29 Thread Jonathan Wakely
On Sun, 29 Dec 2024, 13:55 Gerald Pfeifer wrote: > I pushed the following for now, though Thanks! something tells me this is not the > full extent of this issue. Something to dig into when I find more time. > What's your concern? I think the explanation for this is simple, and not likely to b

Re: [PATCH] libstdc++-v3/testsuite/.../year_month_day/3.cc, 4.cc: Cut down for simulators

2024-12-28 Thread Jonathan Wakely
On Sat, 28 Dec 2024, 07:01 Hans-Peter Nilsson, wrote: > I can't think of a straightforward way to prune these two > similar tests to a more meaningful subset: there's no easy > pruning to each Nth iteration instead of every iteration. > Hopefully exiting the loop after a million runs at the > beg

Re: [PATCH 1/2] libstdc++: don't implicit-construct _Yielded_decvref [PR118022]

2024-12-26 Thread Jonathan Wakely
On Thu, 26 Dec 2024, 10:03 Jonathan Wakely, wrote: > > > On Wed, 25 Dec 2024, 01:20 Arsen Arsenović, wrote: > >> Evening! >> >> This patchset includes fixes for two bugs in libstdc++s implementation >> of std::generator, namely PR118196 and PR118022. >

Re: [PATCH 1/2] libstdc++: don't implicit-construct _Yielded_decvref [PR118022]

2024-12-26 Thread Jonathan Wakely
On Wed, 25 Dec 2024, 01:20 Arsen Arsenović, wrote: > Evening! > > This patchset includes fixes for two bugs in libstdc++s implementation > of std::generator, namely PR118196 and PR118022. > > There's little to note about these fixes. > > Tested on x86_64-pc-linux-gnu via 'make -j17 check' with 's

Re: [PATCH 2/2] libstdc++: add missing return in generator assignment operator [PR118196]

2024-12-26 Thread Jonathan Wakely
On Wed, 25 Dec 2024, 01:15 Arsen Arsenović, wrote: > libstdc++-v3/ChangeLog: > > PR libstdc++/118196 > * include/std/generator (generator::operator=(generator)): Add > missing 'return *this;'. > * > testsuite/24_iterators/range_generators/move-assign-missing-return

Re: [PATCH v2] libstdc++: add initializer_list constructor to std::span (P2447)

2024-12-20 Thread Jonathan Wakely
On Fri, 20 Dec 2024 at 14:21, Giuseppe D'Angelo wrote: > > Hi, > > On 20/12/2024 13:37, Jonathan Wakely wrote: > > > > With this, I get seven PASS results for this test. > > Thank you; I was just thinking, would it be simpler to split the test in >

Re: [PATCH v2] libstdc++: add initializer_list constructor to std::span (P2447)

2024-12-20 Thread Jonathan Wakely
On 19/12/24 14:49 +0100, Giuseppe D'Angelo wrote: diff --git a/libstdc++-v3/testsuite/23_containers/span/init_list_cons_neg.cc b/libstdc++-v3/testsuite/23_containers/span/init_list_cons_neg.cc new file mode 100644 index 000..ef43541b769 --- /dev/null +++ b/libstdc++-v3/testsuite/23_conta

Re: [PATCH v2] libstdc++: add initializer_list constructor to std::span (P2447)

2024-12-20 Thread Jonathan Wakely
On Thu, 19 Dec 2024 at 13:49, Giuseppe D'Angelo wrote: > > Hello, > > On 19/12/2024 13:27, Jonathan Wakely wrote: > > I was about to push this and realised it's missing a Signed-off-by > > tag. I assume you meant to contribute this under the DCO terms, as >

Re: [PATCH v2] libstdc++: add initializer_list constructor to std::span (P2447)

2024-12-19 Thread Jonathan Wakely
On Thu, 12 Dec 2024 at 14:24, Giuseppe D'Angelo wrote: > > Hi, > > On 12/12/2024 01:04, Jonathan Wakely wrote: > >> I'll prepare a patch to do that, > > Et voila: > > https://gcc.gnu.org/pipermail/gcc-patches/2024-December/671432.html > > Thanks!

Re: [PATCH] Add fancy pointer support in std::map/set

2024-12-18 Thread Jonathan Wakely
o trunk - thanks for all the work on this! > > François > > > On 09/12/2024 07:05, François Dumont wrote: > > > > On 04/12/2024 22:48, Jonathan Wakely wrote: > >> On 04/12/24 19:27 +0100, François Dumont wrote: > >>> Hi > >>> > >&g

[PATCH] libstdc++: Handle errors from strxfrm in std::collate::transform [PR85824]

2024-12-18 Thread Jonathan Wakely
std::regex builds a cache of equivalence classes by calling std::regex_traits::transform_primary(c) for every char, which then calls std::collate::transform which calls strxfrm. On several targets strxfrm fails for non-ASCII characters. Because strxfrm has no return value reserved to indicate an er

Re: [PATCH] Use __builtin_addressof in std::addressof

2024-12-18 Thread Jonathan Wakely
On Wed, 18 Dec 2024 at 18:39, François Dumont wrote: > > Hi > > As proposed on another thread here is the patch to make std::__addressof > and std::addressof compile time equivalent. > > Maybe not entirely because of the [[__nodiscard__]] on std::addressof > but still closer. > > libstdc++: H

Re: [PATCH 2/2][libstdc++]: Adjust probabilities of hashmap loop conditions

2024-12-18 Thread Jonathan Wakely
On Wed, 18 Dec 2024 at 14:14, Tamar Christina wrote: > > > e791e52ec329277474f3218d8a44cd37ded14ac3..8101d868d0c5f7ac4f97931a > > > ffcf71d826c88094 100644 > > > > --- a/libstdc++-v3/include/bits/hashtable.h > > > > +++ b/libstdc++-v3/include/bits/hashtable.h > > > > @@ -2171,7 +2171,7 @@ _GLIBCXX

Re: [PATCH] libstdc++: Call regex_traits::transform_primary() only when necessary

2024-12-18 Thread Jonathan Wakely
On Sat, 16 Nov 2024 at 11:20, Luca Bacci wrote: > > This is both a performance optimization and a partial fix for > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98723. > > This commit fixes the issue for bracket expressions that do not > depend on the locale's collation facet. Examples: > > * Cha

[PATCH] libstdc++: Add missing character to __to_wstring_numeric map

2024-12-17 Thread Jonathan Wakely
The mapping from char to wchar_t needs to handle 'i' and 'I' but those were absent from the table that is used for some non-ASCII encodings. libstdc++-v3/ChangeLog: * include/bits/basic_string.h (__to_wstring_numeric): Add 'i' and 'I' to mapping. --- Tested x86_64-linux. libstd

[PATCH] libstdc++: Fix std::deque::emplace calling wrong _M_insert_aux [PR90389]

2024-12-17 Thread Jonathan Wakely
We have several overloads of std::deque::_M_insert_aux, one of which is variadic and called by std::deque::emplace. With a suitable set of arguments to emplace, it's possible for one of the non-variadic _M_insert_aux overloads to be selected by overload resolution, making emplace ill-formed. Renam

Re: [PATCH] libstdc++: Fix future.wait_until when given a negative time_point

2024-12-17 Thread Jonathan Wakely
On Tue, 17 Dec 2024 at 19:38, Jonathan Wakely wrote: > > On Wed, 31 Jul 2024 at 22:39, Jonathan Wakely wrote: > > > > On Wed, 24 Jul 2024 at 14:14, William Tsai wrote: > > > > > > The template `future.wait_until` will expand to > > > `_M

[PATCH] libstdc++: Clear std::priority_queue after moving from it [PR118088]

2024-12-17 Thread Jonathan Wakely
We don't know what state an arbitrary sequence container will be in after moving from it, so a moved-from std::priority_queue needs to clear the moved-from container to ensure it doesn't contain elements that are in an invalid order for the queue. An alternative would be to call std::make_heap agai

Re: [PATCH] libstdc++: Fix future.wait_until when given a negative time_point

2024-12-17 Thread Jonathan Wakely
On Wed, 31 Jul 2024 at 22:39, Jonathan Wakely wrote: > > On Wed, 24 Jul 2024 at 14:14, William Tsai wrote: > > > > The template `future.wait_until` will expand to > > `_M_load_and_test_until_impl` where it will call > > `_M_load_and_test_until*` with given tim

[committed] libstdc++: Fix -Wparentheses warning in Debug Mode macro

2024-12-17 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * include/debug/safe_local_iterator.h (_GLIBCXX_DEBUG_VERIFY_OPERANDS): Add parentheses to avoid -Wparentheses warning. --- Tested x86_64-linux. Pushed to trunk. libstdc++-v3/include/debug/safe_local_iterator.h | 2 +- 1 file changed, 1 insertion(+), 1 de

[committed] libstdc++: Fix std::deque::insert(pos, first, last) undefined behaviour [PR118035]

2024-12-17 Thread Jonathan Wakely
Inserting an empty range into a std::deque results in undefined calls to either std::copy, std::copy_backward, std::move, or std::move_backward. We call those algos with invalid arguments where the output range is the same as the input range, e.g. std::copy(first, last, first) which violates the p

Re: [PATCH] Add fancy pointer support in std::map/set

2024-12-16 Thread Jonathan Wakely
On Sat, 14 Dec 2024 at 14:59, Jonathan Wakely wrote: > > > > On Mon, 9 Dec 2024, 06:05 François Dumont, wrote: >> >> >> On 04/12/2024 22:48, Jonathan Wakely wrote: >> > On 04/12/24 19:27 +0100, François Dumont wrote: >> >> Hi >> >> &

Re: [PATCH] libstdc++: Move std::basic_ostream to new internal header

2024-12-16 Thread Jonathan Wakely
On Fri, 13 Dec 2024 at 13:45, Jonathan Wakely wrote: > > This adds so that other headers don't need to include > all of , which pulls in all of since C++23 (for the > std::print and std::println overloads in ). This new header > allows the constrained operator<< in t

Re: [PATCH 1/4] libstdc++: Further simplify _Hashtable inheritance hierarchy

2024-12-16 Thread Jonathan Wakely
On Mon, 16 Dec 2024 at 14:26, Jonathan Wakely wrote: > > I've pushed this patch series now, and I hope I'm done with > refactoring _Hashtable. > > I see about a 2% reduction in memory and in compilation time for an > explicit instantiation of std::unordered_list when

Re: [PATCH 1/4] libstdc++: Further simplify _Hashtable inheritance hierarchy

2024-12-16 Thread Jonathan Wakely
7;s something, and I find the code easier to understand now. On Fri, 13 Dec 2024 at 23:07, Jonathan Wakely wrote: > > The main change here is using [[no_unique_address]] instead of the Empty > Base-class Optimization. Using the attribute allows us to use data > members instead of b

Re: [PATCH] Add fancy pointer support in std::map/set

2024-12-14 Thread Jonathan Wakely
On Mon, 9 Dec 2024, 06:05 François Dumont, wrote: > > On 04/12/2024 22:48, Jonathan Wakely wrote: > > On 04/12/24 19:27 +0100, François Dumont wrote: > >> Hi > >> > >> I've completed the synchronization with your equivalent PR for > >> std::li

[PATCH] doc: Fix typos for --enable-host-pie docs in install.texi

2024-12-14 Thread Jonathan Wakely
From: Heiko Eißfeldt gcc/ChangeLog: * doc/install.texi (Configuration): Fix typos in documentation for --enable-host-pie. --- This was reported as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118041 with a patch attached, but I forgot to put the bug number in the commit. Pushed

Re: [PATCH 1/2][libstdc++]: Add inline keyword to _M_locate

2024-12-13 Thread Jonathan Wakely
N.B. All libstdc++ patches should be sent to the libstdc++ list (not just to the names in the MAINTAINERS file). On Sat, 14 Dec 2024 at 01:01, Jonathan Wakely wrote: > > On Fri, 13 Dec 2024 at 17:12, Tamar Christina wrote: > > > > Hi All, > > > > In GCC 12 ther

Re: [PATCH 2/2][libstdc++]: Adjust probabilities of hashmap loop conditions

2024-12-13 Thread Jonathan Wakely
On Fri, 13 Dec 2024 at 17:13, Tamar Christina wrote: > > Hi All, > > We are currently generating a loop which has more comparisons than you'd > typically need as the probablities on the small size loop are such that it > assumes the likely case is that an element is not found. > > This again gener

Re: [PATCH 1/2][libstdc++]: Add inline keyword to _M_locate

2024-12-13 Thread Jonathan Wakely
On Fri, 13 Dec 2024 at 17:12, Tamar Christina wrote: > > Hi All, > > In GCC 12 there was a ~40% regression in the performance of hashmap->find. > > This regression came about accidentally: > > Before GCC 12 the find function was small enough that IPA would inline it even > though it wasn't marked

[PATCH 4/4] libstdc++: Initialize all members of hashtable local iterators

2024-12-13 Thread Jonathan Wakely
Currently the _M_bucket members are left uninitialized for default-initialized local iterators, and then copy construction copies indeterminate values. We should just ensure they're initialized on construction. Setting them to zero makes default-initialization consistent with value-initialization

[PATCH 3/4] libstdc++: Use alias-declarations in bits/hashtable_policy, h

2024-12-13 Thread Jonathan Wakely
This file is only for C++11 and later, so replace typedefs with alias-declarations for clarity. Also remove redundant std:: qualification on size_t, ptrdiff_t etc. We can also remove the result_type, first_argument_type and second_argument_type typedefs from the range hashers. We don't need those

[PATCH 1/4] libstdc++: Further simplify _Hashtable inheritance hierarchy

2024-12-13 Thread Jonathan Wakely
The main change here is using [[no_unique_address]] instead of the Empty Base-class Optimization. Using the attribute allows us to use data members instead of base-classes. That simplifies the inheritance hierarchy, which means less work for the compiler. It also means that ADL has fewer associated

[PATCH 2/4] libstdc++: Simplify storage of hasher in local iterators

2024-12-13 Thread Jonathan Wakely
The fix for PR libstdc++/56267 (relating to the lifetime of the hash object stored in a local iterator) has undefined behaviour, as it relies on being able to call a member function on an empty object that never started its lifetime. Although the member function probably doesn't care about the empt

[PATCH] libstdc++: Move std::basic_ostream to new internal header

2024-12-13 Thread Jonathan Wakely
This adds so that other headers don't need to include all of , which pulls in all of since C++23 (for the std::print and std::println overloads in ). This new header allows the constrained operator<< in to be defined without all of std::format being compiled. We could also replace with in all

[committed] libstdc++: Fix uninitialized data in std::basic_spanbuf::seekoff

2024-12-13 Thread Jonathan Wakely
I noticed a -Wmaybe-uninitialized warning for this function, which turns out to be correct. If the caller passes a valid std::ios_base::seekdir value then there's no problem, but if they pass std::seekdir(999) then we don't initialize the __base variable before adding it to __off. Rather than init

[committed] libstdc++: Swap expressions in noexcept-specifier of ranges::not_equal_to

2024-12-13 Thread Jonathan Wakely
Although this should never make a difference for sensible code, we should really make the expression in the noexcept-specifier match the expression in the function body. libstdc++-v3/ChangeLog: * include/bits/ranges_cmp.h (not_equal_to): Make order of expressions in noexcept-speci

[committed] libstdc++: Fix -Wsign-compare warning in

2024-12-13 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * include/bits/regex.tcc: Fix -Wsign-compare warning. --- Tested x86_64-linux. Pushed to trunk. libstdc++-v3/include/bits/regex.tcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/regex.tcc b/libstdc++-v3/include/bit

[committed] libstdc++: Fix -Wreorder warning in

2024-12-13 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * include/pstl/parallel_backend_tbb.h (__merge_func): Fix order of mem-initializers. --- Tested x86_64-linux. Pushed to trunk. There are still lots of -Wunknown-pragmas/-Wsign-compare/-Wunused warnings in this header though. libstdc++-v3/include/pstl/par

[committed] libstdc++: Fix -Wmisleading-indentation warning in testcase

2024-12-13 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * testsuite/26_numerics/random/random_device/entropy.cc: Fix indentation to avoid -Wmisleading-indentation warning. --- Tested x86_64-linux. Pushed to trunk. .../testsuite/26_numerics/random/random_device/entropy.cc | 2 +- 1 file changed, 1 inserti

[committed] libstdc++: Fix some -Wsign-compare warnings in the testsuite

2024-12-12 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * testsuite/23_containers/unordered_map/modifiers/reserve.cc: Cast to size_t to fix -Wsign-compare warning. * testsuite/23_containers/unordered_set/hash_policy/71181.cc: Likewise. * testsuite/23_containers/unordered_set/insert/move_ra

[committed] libstdc++: Fix -Wsign-compare warnings in bits/hashtable_policy.h

2024-12-12 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * include/bits/hashtable_policy.h (_Local_iterator_base): Fix -Wsign-compare warnings. --- Tested x86_64-linux. Pushed to trunk. libstdc++-v3/include/bits/hashtable_policy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++

[committed] libstdc++: Fix typo in comment in src/c++17/fs_dir.cc

2024-12-12 Thread Jonathan Wakely
libstdc++-v3/ChangeLog: * src/c++17/fs_dir.cc: Fix typo in comment. --- Pushed as obvious. libstdc++-v3/src/c++17/fs_dir.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstdc++-v3/src/c++17/fs_dir.cc b/libstdc++-v3/src/c++17/fs_dir.cc index 8fe9e5e4cc8..f0529f927

Re: [PATCH v2] libstdc++: add initializer_list constructor to std::span (P2447)

2024-12-12 Thread Jonathan Wakely
On Thu, 12 Dec 2024 at 14:24, Giuseppe D'Angelo wrote: > > Hi, > > On 12/12/2024 01:04, Jonathan Wakely wrote: > >> I'll prepare a patch to do that, > > Et voila: > > https://gcc.gnu.org/pipermail/gcc-patches/2024-December/671432.html > > Thanks!

[PATCH] libstdc++: Add lvalue overload for generator::yield_value

2024-12-11 Thread Jonathan Wakely
This was approved in Wrocław as LWG 3899. libstdc++-v3/ChangeLog: * include/std/generator (generator::yield_value): Add overload taking lvalue element_of view, as per LWG 3899. --- The issue suggests that this change avoids creating a new coroutine frame, so I thought if I used a

Re: [PATCH] libstdc++: add initializer_list constructor to std::span (P2447)

2024-12-11 Thread Jonathan Wakely
On Wed, 11 Dec 2024 at 22:53, Jonathan Wakely wrote: > > On 03/12/24 17:05 +0100, Giuseppe D'Angelo wrote: > >Hello, > > > >The attached patch adds the span(initializer_list) constructor, added > >by P2447R6 for C++26. > > > >It seems that GCC is so

[PATCH] libstdc++: Avoid redundant assertions in std::span constructors

2024-12-11 Thread Jonathan Wakely
Any std::span constructor with a runtime length has a precondition that the length is equal to N (except when N == std::dynamic_extent). Currently every constructor with a runtime length does: if constexpr (extent != dynamic_extent) __glibcxx_assert(n == extent); We can move those assertions i

Re: [PATCH] libstdc++: add initializer_list constructor to std::span (P2447)

2024-12-11 Thread Jonathan Wakely
On 03/12/24 17:05 +0100, Giuseppe D'Angelo wrote: Hello, The attached patch adds the span(initializer_list) constructor, added by P2447R6 for C++26. It seems that GCC is somewhat aggressive with its -Winit-list-lifetime warning, which actively interferes with this feature. The idea of the n

Re: [PATCH] libstdc++: add initializer_list constructor to std::span (P2447)

2024-12-11 Thread Jonathan Wakely
On Wed, 11 Dec 2024 at 21:18, Giuseppe D'Angelo wrote: > > On 11/12/2024 21:41, Jonathan Wakely wrote: > > Hmm, the warning is useful if somebody does: > > > > std::span s({1,2,3}); > > > > So I think we do want the warning, but maybe give it a special

Re: [PATCH] libstdc++: add initializer_list constructor to std::span (P2447)

2024-12-11 Thread Jonathan Wakely
On Tue, 3 Dec 2024 at 16:07, Giuseppe D'Angelo wrote: > > Hello, > > The attached patch adds the span(initializer_list) constructor, added by > P2447R6 for C++26. > > It seems that GCC is somewhat aggressive with its -Winit-list-lifetime > warning, which actively interferes with this feature. The

[PATCH v2] libstdc++: Remove constraints on std::generator::promise_type::operator new

2024-12-11 Thread Jonathan Wakely
On Wed, 11 Dec 2024 at 14:59, Arsen Arsenović wrote: > > Jonathan Wakely writes: > > >> + for (auto _ : gen("const This& argument", std::allocator_arg , &mr)) > > > > I have no idea what the promise_type::operator new overload that takes > >

  1   2   3   4   5   6   7   8   9   10   >