- Jan 24, 2025
-
-
GCC Administrator authored
-
- Jan 23, 2025
-
-
Jan Hubicka authored
the following testcase: bool f(const std::vector<bool>& v, std::size_t x) { return v[x]; } is compiled as: f(std::vector<bool, std::allocator<bool> > const&, unsigned long): testq %rsi, %rsi leaq 63(%rsi), %rax movq (%rdi), %rdx cmovns %rsi, %rax sarq $6, %rax leaq (%rdx,%rax,8), %rdx movq %rsi, %rax sarq $63, %rax shrq $58, %rax addq %rax, %rsi andl $63, %esi subq %rax, %rsi jns .L2 addq $64, %rsi subq $8, %rdx .L2: movl $1, %eax shlx %rsi, %rax, %rax andq (%rdx), %rax setne %al ret which is quite expensive for simple bit access in a bitmap. The reason is that the bit access is implemented using iterators return begin()[__n]; Which in turn cares about situation where __n is negative yielding the extra conditional. _GLIBCXX20_CONSTEXPR void _M_incr(ptrdiff_t __i) { _M_assume_normalized(); difference_type __n = __i + _M_offset; _M_p += __n / int(_S_word_bit); __n = __n % int(_S_word_bit); if (__n < 0) { __n += int(_S_word_bit); --_M_p; } _M_offset = static_cast<unsigned int>(__n); } While we can use __builtin_unreachable to declare that __n is in range 0...max_size () but I think it is better to implement it directly, since resulting code is shorter and much easier to optimize. We now porduce: .LFB1248: .cfi_startproc movq (%rdi), %rax movq %rsi, %rdx shrq $6, %rdx andq (%rax,%rdx,8), %rsi andl $63, %esi setne %al ret Testcase suggests movq (%rdi), %rax movl %esi, %ecx shrq $5, %rsi # does still need to be 64-bit movl (%rax,%rsi,4), %eax btl %ecx, %eax setb %al retq Which is still one instruction shorter. libstdc++-v3/ChangeLog: PR target/80813 * include/bits/stl_bvector.h (vector<bool, _Alloc>::operator []): Do not use iterators. gcc/testsuite/ChangeLog: PR target/80813 * g++.dg/tree-ssa/bvector-3.C: New test.
-
- Jan 21, 2025
-
-
GCC Administrator authored
-
- Jan 20, 2025
-
-
Giuseppe D'Angelo authored
As reported in PR118185, std::ranges::clamp does not correctly forward the projected value to the comparator. Add the missing forward. libstdc++-v3/ChangeLog: PR libstdc++/118185 PR libstdc++/100249 * include/bits/ranges_algo.h (__clamp_fn): Correctly forward the projected value to the comparator. * testsuite/25_algorithms/clamp/118185.cc: New test. Signed-off-by:
Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by:
Patrick Palka <ppalka@redhat.com> Reviewed-by:
Jonathan Wakely <jwakely@redhat.com>
-
- Jan 17, 2025
-
-
GCC Administrator authored
-
- Jan 16, 2025
-
-
Jonathan Wakely authored
This adds <bits/ostream.h> so that other headers don't need to include all of <ostream>, which pulls in all of <format> since C++23 (for the std::print and std::println overloads in <ostream>). This new header allows the constrained operator<< in <bits/unique_ptr.h> to be defined without all of std::format being compiled. We could also replace <ostream> with <bits/ostream.h> in all of <istream>, <fstream>, <sstream>, and <spanstream>. That seems more likely to cause problems for users who might be expecting <sstream> to define std::endl, for example. Although the standard doesn't guarantee that, it is more reasonable than expecting <memory> to define it! We can look into making those changes for GCC 16. libstdc++-v3/ChangeLog: PR libstdc++/99995 * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/bits/unique_ptr.h: Include bits/ostream.h instead of ostream. * include/std/ostream: Include new header. * include/bits/ostream.h: New file.
-
Jonathan Wakely authored
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/c++17/fs_ops.cc (fs::equivalent): Remove error reporting for is_other(s1) && is_other(s2) case, as per LWG 2937. * testsuite/27_io/filesystem/operations/pr118158.cc: New test.
-
Jonathan Wakely authored
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. * include/bits/stl_multiset.h: Likewise. * include/bits/stl_set.h: Likewise. * include/bits/stl_tree.h: Likewise.
-
GCC Administrator authored
-
- Jan 15, 2025
-
-
Jonathan Wakely authored
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.
-
Jonathan Wakely authored
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. Others (such as prepend_range) are not valid for std::set at all. Also fix uses of internal feature test macros in two other tests, which should use the standard __cpp_lib_xxx macros. libstdc++-v3/ChangeLog: * testsuite/23_containers/set/requirements/explicit_instantiation/alloc_ptr.cc: Guard node extraction checks with feature test macro. Remove calls to non-existent range members. * testsuite/23_containers/forward_list/requirements/explicit_instantiation/alloc_ptr.cc: Use standard macro not internal one. * testsuite/23_containers/list/requirements/explicit_instantiation/alloc_ptr.cc: Likewise.
-
Jonathan Wakely authored
libstdc++-v3/ChangeLog: PR libstdc++/109849 * include/bits/vector.tcc (vector::_M_range_insert): Fix reversed args in length calculation.
-
Jonathan Wakely authored
libstdc++-v3/ChangeLog: * testsuite/28_regex/traits/char/transform_primary.cc: Fix subclause numbering in references to the standard.
-
Jakub Jelinek authored
c++: Delete defaulted operator <=> if std::strong_ordering::equal doesn't convert to its rettype [PR118387] Note, the PR raises another problem. If on the same testcase the B b; line is removed, we silently synthetize operator<=> which will crash at runtime due to returning without a return statement. That is because the standard says that in that case it should return static_cast<int>(std::strong_ordering::equal); but I can't find anywhere wording which would say that if that isn't valid, the function is deleted. https://eel.is/c++draft/class.compare#class.spaceship-2.2 seems to talk just about cases where there are some members and their comparison is invalid it is deleted, but here there are none and it follows https://eel.is/c++draft/class.compare#class.spaceship-3.sentence-2 So, we synthetize with tf_none, see the static_cast is invalid, don't add error_mark_node statement silently, but as the function isn't deleted, we just silently emit it. Should the standard be amended to say that the operator should be deleted even if it has no elements and the static cast from https://eel.is/c++draft/class.compare#class.spaceship-3.sentence-2 On Fri, Jan 10, 2025 at 12:04:53PM -0500, Jason Merrill wrote: > That seems pretty obviously what we want, and is what the other compilers > implement. This patch implements it then. 2025-01-15 Jakub Jelinek <jakub@redhat.com> PR c++/118387 * method.cc (build_comparison_op): Set bad if std::strong_ordering::equal doesn't convert to rettype. * g++.dg/cpp2a/spaceship-err6.C: Expect another error. * g++.dg/cpp2a/spaceship-synth17.C: Likewise. * g++.dg/cpp2a/spaceship-synth-neg6.C: Likewise. * g++.dg/cpp2a/spaceship-synth-neg7.C: New test. * testsuite/25_algorithms/default_template_value.cc (Input::operator<=>): Use auto as return type rather than bool.
-
- Jan 13, 2025
-
-
GCC Administrator authored
-
- Jan 12, 2025
-
-
Torbjörn SVENSSON authored
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 problem can be found in sim_load where it calls remote_spawn without an input file). libstdc++-v3/ChangeLog: * testsuite/27_io/print/1.cc: Allow both LF and CRLF in test. * testsuite/27_io/print/3.cc: Likewise. Signed-off-by:
Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
-
Torbjörn SVENSSON authored
Test assumes libatomic.a is always available, but for some embedded targets, there is no libatomic.a and the test thus fail. libstdc++-v3/ChangeLog: * testsuite/29_atomics/atomic_float/compare_exchange_padding.cc: Use effective-target libatomic_available. Signed-off-by:
Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
-
- Jan 11, 2025
-
-
GCC Administrator authored
-
- Jan 10, 2025
-
-
Jonathan Wakely authored
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) | ~~~~~~~~~~~~~^~~~ libstdc++-v3/ChangeLog: * include/bits/atomic_futex.h (__atomic_futex_unsigned): Remove names of unused parameters in non-futex implementation.
-
- Jan 09, 2025
-
-
GCC Administrator authored
-
- Jan 08, 2025
-
-
Jonathan Wakely authored
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__]].
-
Jonathan Wakely authored
libstdc++-v3/ChangeLog: PR libstdc++/118260 * python/hook.in: Run 'skip' commands for some simple accessor functions.
-
Nicolas Werner authored
std::to_underlying was missing from the std module introduced in r15-5366-g7db55c0ba1baaf. This patch adds the missing export for this utility. libstdc++-v3/ChangeLog: PR libstdc++/106852 * src/c++23/std.cc.in (to_underlying): Add. Signed-off-by:
Nicolas Werner <nicolas.werner@hotmail.de>
-
Jonathan Wakely authored
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 <cxxx> headers. A similar change is needed in std.cc.in for the <chrono> features that depend on the SSO std::string, guarded with a __cpp_lib_chrono value indicating full C++20 support. The conditions for <cmath> are omitted from this change, as there are a large number of them. That probably needs to be fixed. libstdc++-v3/ChangeLog: PR libstdc++/118177 * src/c++23/std-clib.cc.in: Use preprocessor conditions for names which are not always defined. * src/c++23/std.cc.in: Likewise.
-
Jonathan Wakely authored
libstdc++-v3/ChangeLog: * include/std/span: Fix indentation.
-
Giuseppe D'Angelo authored
This commit implements P2447R6. The code is straightforward (just one extra constructor, with constraints and conditional explicit). I decided to suppress -Winit-list-lifetime because otherwise it would give too many false positives. The new constructor is meant to be used as a parameter-passing interface (this is a design choice, see P2447R6/§2) and, as such, the initializer_list won't dangle despite GCC's warnings. The new constructor isn't 100% backwards compatible. A couple of examples are included in Annex C, but I have also lifted some more from R4. A new test checks for the old and the new behaviors. libstdc++-v3/ChangeLog: * include/bits/version.def: Add the new feature-testing macro. * include/bits/version.h: Regenerate. * include/std/span: Add constructor from initializer_list. * testsuite/23_containers/span/init_list_cons.cc: New test. * testsuite/23_containers/span/init_list_cons_neg.cc: New test. Signed-off-by:
Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
-
Jonathan Wakely authored
Any std::span<T, N> 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 into the __detail::__extent_storage<N> constructor so they are only done in one place. To avoid checking the assertions when we have a constant length we can add a second constructor which is consteval and takes a integral_constant<size_t, N> argument. The std::span constructors can pass a size_t for runtime lengths and a std::integral_constant<size_t, N> for constant lengths that don't need to be checked. The __detail::__extent_storage<dynamic_extent> specialization only needs one constructor, as a std::integral_constant<size_t, N> argument can implicitly convert to size_t. For the member functions that return a subspan with a constant extent we return std::span<T,C>(ptr, C) which is redundant in two ways. Repeating the constant length C when it's already a template argument is redundant, and using the std::span(T*, size_t) constructor implies a runtime length which will do a redundant assertion check. Even though that assertion won't fail and should be optimized away, it's still unnecessary code that doesn't need to be instantiated and then optimized away again. We can avoid that by adding a new private constructor that only takes a pointer (wrapped in a custom tag struct to avoid accidentally using that constructor) and automatically sets _M_extent to the correct value. libstdc++-v3/ChangeLog: * include/std/span (__detail::__extent_storage): Check precondition in constructor. Add consteval constructor for valid lengths and deleted constructor for invalid constant lengths. Make member functions always_inline. (__detail::__span_ptr): New class template. (span): Adjust constructors to use a std::integral_constant value for constant lengths. Declare all specializations of std::span as friends. (span::first<C>, span::last<C>, span::subspan<O,C>): Use new private constructor. (span(__span_ptr<T>)): New private constructor for constant lengths.
-
Jonathan Wakely authored
std::regex builds a cache of equivalence classes by calling std::regex_traits<char>::transform_primary(c) for every char, which then calls std::collate<char>::transform which calls strxfrm. On several targets strxfrm fails for non-ASCII characters. Because strxfrm has no return value reserved to indicate an error, some implementations return INT_MAX or SIZE_MAX. This causes std::collate::transform to try to allocate a huge buffer, which is either very slow or throws std::bad_alloc. We should check errno after calling strxfrm to detect errors and then throw a more appropriate exception instead of trying to allocate a huge buffer. Unfortunately the std::collate<C>::_M_transform function has a non-throwing exception specifier, so we can't do the error handling there. As well as checking errno, this patch changes std::collate::do_transform to use __builtin_alloca for small inputs, and to use RAII to deallocate the buffers used for large inputs. This change isn't sufficient to fix the three std::regex bugs caused by the lack of error handling in std::collate::do_transform, we also need to make std::regex_traits::transform_primary handle exceptions. This change also attempts to make transform_primary closer to the effects described in the standard, by not even attempting to use std::collate if the locale's std::collate facet has been replaced (see PR 118105). Implementing the correct effects for transform_primary requires RTTI, so that we don't use some user-defined std::collate facet with unknown semantics. When -fno-rtti is used transform_primary just returns an empty string, making equivalence classes unusable in std::basic_regex. That's not ideal, but I don't have any better ideas. I'm unsure if std::regex_traits<C>::transform_primary is supposed to convert the string to lower case or not. The general regex traits requirements ([re.req] p20) do say "when character case is not considered" but the specification for the std::regex_traits<char> and std::regex_traits<wchar_t> specializations ([re.traits] p7) don't say anything about that. With the r15-6317-geb339c29ee42aa change, transform_primary is not called unless the regex actually uses an equivalence class. But using an equivalence class would still fail (or be incredibly slow) on some targets. With this commit, equivalence classes should be usable on all targets, without excessive memory allocations. Arguably, we should not even try to call transform_primary for any char values over 127, since they're never valid in locales that use UTF-8 or 7-bit ASCII, and probably for other charsets too. Handling 128 exceptions for every std::regex compilation is very inefficient, but at least it now works instead of failing with std::bad_alloc, and no longer allocates 128 x 2GB. Maybe for C++26 we could check the locale's std::text_encoding and use that to decide whether to cache equivalence classes for char values over 127. libstdc++-v3/ChangeLog: PR libstdc++/85824 PR libstdc++/94409 PR libstdc++/98723 PR libstdc++/118105 * include/bits/locale_classes.tcc (collate::do_transform): Check errno after calling _M_transform. Use RAII type to manage the buffer and to restore errno. * include/bits/regex.h (regex_traits::transform_primary): Handle exceptions from std::collate::transform and do not try to use std::collate for user-defined facets.
-
Jonathan Wakely authored
The current check for negative times (i.e. before the epoch) only checks for a negative number of seconds. For a time 1ms before the epoch the seconds part will be zero, but the futex syscall will still fail with an EINVAL error. Extend the check to handle this case. This change adds a redundant check in the headers too, so that we avoid even calling into the library for negative times. Both checks can be marked [[unlikely]]. The check in the headers avoids the cost of splitting the time into seconds and nanoseconds and then making a PLT call. The check inside the library matches where we were checking already, and fixes existing binaries that were compiled against older headers but use a newer libstdc++.so.6 at runtime. libstdc++-v3/ChangeLog: PR libstdc++/118093 * include/bits/atomic_futex.h (_M_load_and_test_until_impl): Return false for times before the epoch. * src/c++11/futex.cc (_M_futex_wait_until): Extend check for negative times to check for subsecond times. Add unlikely attribute. (_M_futex_wait_until_steady): Likewise. * testsuite/30_threads/future/members/118093.cc: New test.
-
Jonathan Wakely authored
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. Rename the variadic _M_insert_aux to _M_emplace_aux so that calls to emplace never select an _M_insert_aux overload. Also add an inline _M_insert_aux for the const lvalue overload that is called from insert(const_iterator, const value_type&). libstdc++-v3/ChangeLog: PR libstdc++/90389 * include/bits/deque.tcc (_M_insert_aux): Rename variadic overload to _M_emplace_aux. * include/bits/stl_deque.h (_M_insert_aux): Define inline. (_M_emplace_aux): Declare. * testsuite/23_containers/deque/modifiers/emplace/90389.cc: New test.
-
Jonathan Wakely authored
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.
-
Jonathan Wakely authored
libstdc++-v3/ChangeLog: * doc/xml/manual/evolution.xml: Replace invalid <variable> elements with <varname>. * doc/html/*: Regenerate.
-
- Jan 02, 2025
-
-
Jakub Jelinek authored
-
Jakub Jelinek authored
-
Jakub Jelinek authored
Rotate ChangeLog files for ChangeLogs with yearly cadence. Also remove empty lines before Form Feed line.
-
GCC Administrator authored
-
- Jan 01, 2025
-
-
Gerald Pfeifer authored
Commit 544be2be in 2019 remove Profile Mode and associated docs. Now also remove generated HTML files. libstdc++-v3: * doc/html/manual/profile_mode.html: Delete. * doc/html/manual/profile_mode_api.html: Ditto. * doc/html/manual/profile_mode_cost_model.html: Ditto. * doc/html/manual/profile_mode_design.html: Ditto. * doc/html/manual/profile_mode_devel.html: Ditto. * doc/html/manual/profile_mode_impl.html: Ditto.
-
- Dec 30, 2024
-
-
GCC Administrator authored
-
- Dec 29, 2024
-
-
Gerald Pfeifer authored
Commit 544be2be in 2019 remove Profile Mode and associated docs including the XML version of profile_mode_diagnostics.html. Somehow the latter survived until now. Simply delete it as well. libstdc++-v3: * doc/html/manual/profile_mode_diagnostics.html: Delete.
-
Hans-Peter Nilsson authored
These two long-running tests happened to fail for me when run in parallel (nprocs - 1) compared to a serial run, for target mmix on my laptop. The runtime is 3m40s for 3.cc before this change, and 0.9s afterwards. * testsuite/std/time/year_month_day/3.cc (test01): Add ifdeffery to limit the tested dates. For simulators, pass start and end dates limiting the tested range to 100000 days, centered on days (0). * testsuite/std/time/year_month_day/4.cc: Ditto.
-