We don't want to export std::vprint_unicode etc. from libstdc++.so yet,
but we can give users the option of improving compile times by getting
the definitions of the std::print internals from libstdc++exp.a instead.
This commit adds a macro, _GLIBCXX_NO_INLINE_PRINT, which disables the
inline definitions of std::vprint_unicode etc. so that extern
definitions in libstdc++exp.a can be used instead.
With this change compiling a helloworld using std::print goes from 8s to
under 2s with trunk. For release branches with --enable-checking=release
we should see even faster times. The object file size is also
dramatically smaller, because there's just a single call to an extern
function instead of instantiating the entire std::print and std::format
implementation inline.
libstdc++-v3/ChangeLog:
PR libstdc++/124410
* doc/html/*: Regenerate.
* doc/xml/manual/using.xml (_GLIBCXX_NO_INLINE_PRINT): Document
macro.
* include/Makefile.am: Add bits/print.h and bits/ostream_print.h
headers.
* include/Makefile.in: Regenerate.
* include/std/ostream (vprint_nonunicode, vprint_unicode): Move
definitions to new bits/ostream_print.h header.
* include/std/print (__format::_File_sink, vprint_nonunicode)
(vprint_nonunicode_buffered, vprint_unicode)
(vprint_unicode_buffered): Move definitions to new bits/print.h
header.
* src/c++23/print.cc: Include new headers to define symbols for
inline print functions.
* include/bits/ostream_print.h: New file.
* include/bits/print.h: New file.
This patch extracts a __format::__do_vformat_to for the _Sink_iter
(and matching format context) and exports explicit instantiations
of it for char and wchar_t. As every format function is implementing
as delegating to one of these overloads, this significantly reduces
the compilation time.
Instantiating __format::__do_vformat_to triggers specializations of
formatters for types stored in basic_format_arg directly (arithmetic
types, strings). In case when their behavior depends on the TU specific
configuration, only one configuration can be exported from shared
lib. In case of beforementioned formatters:
* ? (debug mode) is accepted in for strings and characters
* multibyte utf-8 encoded character is accepted as fill when the
literal encoding is Unicode.
The first issue is addressed by this patch, by declaring extern
definition only for the C++20. We will need to reconsider how to
handle the specifiers when C++23 becomes stable.
The literal encoding is handled by adding a second template parameter
to __do_vformat_to overload, that is initialized with 1 if literal
encoding is Unicode (the parameter has unsigned type to allow more
information to be encoded). This allows library to export implementation
for Unicode literal encoding (format-inst.cc is compiled with appropriate
flag), by declaring extern specialization only for value 1.
libstdc++-v3/ChangeLog:
* config/abi/pre/gnu.ver (GLIBCXX_3.4): Exclude exports
of std::basic_fo* (matching basic_format_context).
(GLIBCXX_3.4.35): Export __format::__do_vformat_to
specializations for _Sink_iter and char/wchar_t.
* include/std/format: (__format::__do_vformat_to):
Extract overload accepting _Sink_iter and provide extern
explicit specialization for char/wchar_t in C++20 mode.
* src/c++20/Makefile.am: Add format-inst.cc.
* src/c++20/Makefile.in: Regenerate.
* src/c++20/format-inst.cc: New file defining explicit
instantiation.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
The philox counter increment that happens in
philox_engine::_M_transition(), applies +1 to _M_x[0] before the bitwise
OR with (_M_x[1] << __w), so the carry from _M_x[0] is merged into the
_M_x[1] portion rather than being added to it. This causes the counter
to cycle prematurely and never advance past {0, 0, 1, 2^w - 1}.
Fix by changing operations order, which results in forming the
full-width value from _M_x[1]:_M_x[0] and then adding 1 on both the n ==
4 and n == 2 paths.
libstdc++-v3/ChangeLog:
* include/bits/random.tcc (philox_engine::_M_transtiion): Fix
counter increment to propagate carry correctly.
* testsuite/26_numerics/random/philox_engine/operators/counter_carry.cc:
New test.
Signed-off-by: Elena Tyuleneva <elena.tyuleneva@intel.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
While testing a patch for std::philox_engine I noticed that
instantiating std::philox_engine with n=2 and w=64 fails on targets
without __int128, because it relies on an implicit conversion from the
intermediate counter type to the result type. When w=64 and the target
doesn't support __int128, we use the __rand_uint128 class type for the
intermediate counter values, but that does not support implicit
conversion to integral types.
This adds the necessary casts to make the conversions explicit.
libstdc++-v3/ChangeLog:
* include/bits/random.tcc (philox_engine::_M_transition): Cast
intermediate values to result_type for n=2 case.
The following patch attempts to implement LWG4483. As written in the
approved resolution, some checks are done on strip_array_types (valuet)
rather than on valuet and one is skipped. Tomasz on IRC reasoned why
input_range should otherwise already ensure we see similar type, so just
for the possibility of fuzzed <meta> the patch adds some verification.
And as the array cases are contiguous, instead of actually recursing (for
which we'd need to have lvalue of the *it rather than prvalue) it just
walks the CONSTRUCTORs for the arrays and handles the elts in there
recursively.
The <meta> changes do exactly what the LWG4483 change says to do.
2026-04-15 Jakub Jelinek <jakub@redhat.com>
* reflect.cc (adjust_array_elt): New function.
(get_range_elts): Implement LWG4483 - Multidimensional arrays are not
supported by meta::reflect_constant_array and related functions.
Handle ARRAY_TYPE valuet. Don't unshare_expr in the class valuet case,
get_template_param_object will unshare.
* g++.dg/reflect/reflect_constant_array9.C: New test.
* g++.dg/reflect/reflect_constant_array10.C: New test.
* g++.dg/reflect/reflect_constant_array11.C: New test.
* g++.dg/reflect/define_static_array6.C: New test.
* g++.dg/reflect/define_static_object2.C: Uncomment older tests and
fix them, add tests for unions.
* include/std/meta (define_static_object): Adjust for LWG4483 changes
- handle unions and arrays differently.
Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
This implements LWG4550: Need new feature test macros for <stdckdint.h>
and <stdbit.h>.
libstdc++-v3/ChangeLog:
* include/bits/version.def (stdbit_h, stdckdint_h): Define.
* include/bits/version.h: Regenerate.
* include/c_compatibility/stdbit.h (__cpp_lib_stdbit_h): Define
and use it in guards.
* include/c_compatibility/stdckdint.h (__cpp_lib_stdckdint_h):
Define and use it in guards.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This implements P3978R3: constant_wrapper should unwrap on call and subscript.
The operator() and operator[] are now fallback to calling corresponding
operation on value, if either arguments are not constant_wrapper like, or
the result of the invocation is not usable as non-type template argument
(non-constant). The call operator is also now defined in terms of invoke,
to support member pointers.
The noexcept specification is simplified, by observing that creating a
default constructed (constant_wrapper<value(....)>{}) is never throwing
operation. Nested requires expr is used for short-circuting, and thus
avoid checking viability of the operation on the value with
constant_wrapper only (see PoisonedAdd, PoisonedIndex in tests).
libstdc++-v3/ChangeLog:
* include/bits/version.def (constant_wrapped): Updated to 202603L.
* include/bits/version.h: Regenerate.
* include/bits/utility.h (_CwOperators::operator())
(_CwOperators:operator[]): Delete, they are now provided by...
(constant_wrapper::operator(), constant_wrapper::operator[]):
Define.
* testsuite/20_util/constant_wrapper/generic.cc: Add additional
test cases for invoke and subscript.
* testsuite/20_util/constant_wrapper/version.cc: Update tested
value.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
There is no need to use std::__addressof in post-C++11 code.
libstdc++-v3/ChangeLog:
* include/bits/hashtable.h: Replace usages of std::__addressof with
std::addressof.
* include/bits/hashtable_policy.h: Likewise.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
This implements P3886R0: Wording for AT1-057, by defining the
__cpp_lib_replaceable_contract_violation_handler. The macro is defined
only if contracts are supported (i.e. under same conditions as
__cpp_lib_contracts).
GCC supports providing custom violation handler by providing an separate
defintion of handle_contract_violation. This is supported on the targets
that uses ELF format, so the macro is defined for with non-zero value
for them.
libstdc++-v3/ChangeLog:
* include/bits/version.def (replaceable_contract_violation_handler)
[(__cplusplus > 202302L) && (__cpp_contracts >= 202502L)]:
Define to 202603 for ELF targets, and 0 otherwise.
* include/bits/version.h: Regenerate.
* include/std/contracts: Define
__cpp_lib_replaceable_contract_violation_handler.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
SG-10 agreed on using 202604L value for paper P3961R0 that
also updates __cpp_lib_function_ref macro.
libstdc++-v3/ChangeLog:
* include/bits/version.def (function_ref): Bump to 202603L.
* include/bits/version.h: Regenerate.
* testsuite/20_util/function_ref/assign.cc: Remove repeated
check for feature test macro.
* testsuite/20_util/function_ref/cons.cc: Updated checked
value.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This patch implements P3828R1: Rename the to_input view to as_input.
The paper suggest renaming the feature test macro without changing the
value and this patch follows.
libstdc++-v3/ChangeLog:
* include/bits/version.def (ranges_to_input): Rename to...
(ranges_as_input): Rename from ranges_as_input.
* include/bits/version.h: Regenerate.
* include/std/ranges (ranges::to_input_view, views::to_input)
(__detail::__can_to_input, views::_ToInput): Rename to...
(ranges::as_input_view, views::as_input, __detail::__can_as_input)
(views::_AsInput): Rename from above...
* src/c++23/std.cc.in: Rename views::to_input and to_input_view
export.
* testsuite/25_algorithms/contains/1.cc: Replace views::to_input
with views::as_input.
* testsuite/std/ranges/adaptors/to_input/1.cc: Move to...
* testsuite/std/ranges/adaptors/as_input/1.cc: ...here, and replace
views::to_input with views::as_input.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/range_args.C: Replace views::to_input with
views::as_input.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This implements P3217R0 and adds default argument for the value type
templater parameter for uninitialized_fill, uninitialized_fill_n and
their ranges counterpart.
libstdc++-v3/ChangeLog:
* include/bits/ranges_uninitialized.h
(__uninitialized_fill_fn::operator())
(__uninitialized_fill_fn_n::operator()): Add default argument
for _Tp parameter.
* include/bits/stl_uninitialized.h (std::unitialized_fill)
(std::unitialized_fill_n): Likewise.
* include/pstl/glue_memory_defs.h (std::unitialized_fill)
(std::unitialized_fill_n): Likewise.
* include/bits/version.def (algorithm_default_value_type):
Bump to 202603.
* include/bits/version.h: Regenerate.
* testsuite/25_algorithms/default_template_value.cc:
Test for new algorithms.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This implements P3948R1: constant_wrapper is the only tool needed
for passing constant expressions via function arguments.
This changes function_ref from nontype_t to constant_wrapper and
implements the ambiguity check (static_asert in function_ref
from constant_wrapper constructor).
In addition to P3948R1 this also includes the (forgotten) deduction
guide changes suggested in the draft PR [1].
[1] https://github.com/cplusplus/draft/pull/8878
libstdc++-v3/ChangeLog:
* include/bits/funcref_impl.h (function_ref::function_ref):
Change nontype_t parameter to constant_wrapper, and adjust
accordingly. Add static_assert detecting ambigous semantics.
(function_ref::operator=): Detect constant_wrapper rather than
nontype_t.
* include/bits/funcwrap.h (function_ref): Change nontype_t
parameter to constant_wrapper in deduction guides.
* include/bits/utility.h (std::nontype_t, std::nontype)
(std::__is_nontype_v): Remove.
(std::__is_constant_wrapper_v): Define.
* src/c++23/std.cc.in (std::nontype_t, std::nontype):
Remove exports.
* testsuite/20_util/function_ref/cw_cons_neg.cc: New tests
for ambiguity check.
* testsuite/20_util/function_ref/assign.cc: Replace nontype_t
with constant_wrapper and nontype with std::cw.
* testsuite/20_util/function_ref/call.cc: Likewise.
* testsuite/20_util/function_ref/cons.cc: Likewise.
* testsuite/20_util/function_ref/cons_neg.cc: Likewise.
* testsuite/20_util/function_ref/dangling.cc: Likewise.
* testsuite/20_util/function_ref/deduction.cc: Likewise.
* testsuite/20_util/function_ref/mutation.cc: Likewise.
Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
The C++20 standard added new starts_with and ends_with members to
std::basic_string, which were not previously instantiated in the library.
This meant that the extern template declarations had to be disabled for
C++20 mode. With this patch the new members are instantiated in the
library and so the explicit instantiation declarations can be used for
C++20.
Furthermore, basic_string default constructor is now constrained with
is_default_constructible_v<_Alloc> constrains, that is included in
mangled name, so we also need to instantiate and export it.
The new members added by C++23 are still not exported, and so the
explicit instantiation declarations are still disabled for C++23.
libstdc++-v3/ChangeLog:
* config/abi/pre/gnu.ver (GLIBCXX_3.4): Make string exports
less greedy.
(GLIBCXX_3.4.35): Export basic_string default constructor and
starts_with and ends_with members.
* include/bits/basic_string.h: Update __cpluplus checks for C++20.
* include/bits/cow_string.h: Likewise.
* include/bits/basic_string.tcc: Declare explicit instantiations
for C++20 as well as earlier dialects.
* src/c++20/Makefile.am: Add cow-string-inst.cc and
string-inst.cc source files.
* src/c++20/Makefile.in: Regenerate.
* src/c++20/string-inst.cc: New file defining explicit
instantiations for basic_string default constructor and starts_with,
ends_with methods added in C++20
* src/c++20/cow-string-inst.cc: Version of above for cow-stings.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This paper removes the try_append_range from inplace_vector and changes the
return type of try_emplace_back and try_push_back to optional<_Tp&> per:
P4022R0: Remove try_append_range from inplace_vector for now.
P3981R2: Better return types in std::inplace_vector and std::exception_ptr_cast.
The test are also expanded to cover type Y, that is convertible to optional<Y&>,
and require return type to be constructed using in_place.
libstdc++-v3/ChangeLog:
* include/bits/version.def (inplace_vector): Bump to 202603.
* include/bits/version.h: Regenerate.
* include/std/inplace_vector (inplace_vector::try_emplace_back)
(inplace_vector::try_push_back): Change return type to optional<_Tp&>
and adjust implementation accordingly.
(inplace_vector::try_append_range): Remove.
* include/debug/inplace_vector (inplace_vector::try_emplace_back)
(inplace_vector::try_push_back, inplace_vector::try_append_range):
Likewise.
* testsuite/23_containers/inplace_vector/modifiers/single_insert.cc:
Updated check for the optional<T&> return. Added test for type
convertible to optional<T&>
* testsuite/23_containers/inplace_vector/debug/invalidation/try_emplace_back.cc:
Use has_value() to check if engaged optional is returned.
* testsuite/23_containers/inplace_vector/debug/invalidation/try_push_back.cc:
Likewise.
* testsuite/23_containers/inplace_vector/modifiers/multi_insert.cc:
Remove try_append_range tests.
* testsuite/23_containers/inplace_vector/debug/invalidation/try_append_range.cc:
Removed.
* testsuite/23_containers/inplace_vector/version.cc: Updated expected
feature test macro value.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This combines the $n and $nn items into one, which is more consistent
with the EcmaScript docs.
libstdc++-v3/ChangeLog:
* include/bits/regex_constants.h (format_default): Simplify
description of $n in Doxygen comment.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
It doesn't necessarily hold objects, it can hold references too.
libstdc++-v3/ChangeLog:
* include/bits/stl_pair.h (pair): Adjust Doxygen comment.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/chrono.h (floor, ceil, round): Fix Doxygen
comments to use correct parameter name and describe return value
more accurately.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
This fixes some Doxygen warnings caused by inconsistent parameter names,
which do not match the names used in the Doxygen comments:
include/bits/unordered_map.h:899: warning: argument '__x' of command @param is not found in the argument list of std::unordered_map< _Key, _Tp, _Hash, _Pred, _Alloc >::erase(_Kt &&__key)
include/bits/unordered_map.h:899: warning: The following parameter of std::unordered_map::erase(_Kt &&__key) is not documented:
parameter '__key'
libstdc++-v3/ChangeLog:
* include/bits/unordered_map.h (unordered_map::erase(K&&)):
Change parameter name to __x.
* include/bits/unordered_set.h (unordered_set::erase(K&&))
(unordered_multiset::erase(K&&)): Likewise.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/ostream.h (operator<<): Do not include deleted
overloads in @{ group.
* include/bits/stl_queue.h (priority_queue): Add @{ group around
constructors.
* include/bits/unordered_map.h: Remove stray @{. Move #endif to
encompass @} that is within the #if group.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
With the latest version of Doxygen this gives a warning about using
@return on a function that returns void. Stating it explicitly adds very
little value, anybody can see from the signature that a function returns
void.
libstdc++-v3/ChangeLog:
* include/bits/move.h (swap): Remove @return from Doxygen
comment.
* include/bits/stl_algo.h (inplace_merge, shuffle)
(random_shuffle, partial_sort, nth_element, sort)
(stable_sort): Likewise.
* include/bits/stl_algobase.h (iter_swap, fill): Likewise.
* include/bits/stl_deque.h (_Deque_base::_M_initialize_map)
(deque::_M_range_initialize, deque::_M_fill_initialize):
Likewise.
* include/bits/stl_iterator_base_funcs.h (advance): Likewise.
* include/bits/stl_numeric.h (iota): Likewise.
* include/bits/stl_tempbuf.h (return_temporary_buffer):
Likewise.
* include/bits/stl_uninitialized.h (uninitialized_fill):
Likewise.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
This header does not appear to be used anywhere, but Doxygen gives a
warning when processing it:
include/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp:49: warning: More #if's than #endif's found (might be in an included file).
libstdc++-v3/ChangeLog:
* include/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp:
Add missing #endif.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Check the relevant macro for insert_or_assign members, instead of just
checking the value of __cplusplus.
Also use Doxygen grouping to make docs for try_emplace apply to all
three overloads.
libstdc++-v3/ChangeLog:
* include/bits/stl_map.h (map::try_emplace): Move #endif and use
Doxygen's @{ to document all three overloads.
(map::insert_or_assign): Use relevant feature test macro.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
This is last change proposed in P3982R2, so we bump submdspan
value.
libstdc++-v3/ChangeLog:
* include/bits/version.def (submdspan): Update to 202603,
and list all papers in comment.
* include/bits/version.h: Regenerate.
* include/std/mdspan: Replaced std::strided_stride to
std::extent_slice, __is_strided_slice to __is_extent_slice,
_SliceKind::__unit_strided_slice to __unit_stride_slice.
* src/c++23/std.cc.in (std::extent_slice): Replaced
std::strided_slice to std::extent_slice.
* testsuite/23_containers/mdspan/submdspan/canonical_slices.cc:
Replaced all occurences of strided_slice to extent_slice.
* testsuite/23_containers/mdspan/submdspan/canonical_slices_neg.cc:
Likewise.
* testsuite/23_containers/mdspan/submdspan/strided_slice.cc: Move to...
* testsuite/23_containers/mdspan/submdspan/extent_slice.cc: ...here
and handle rename.
* testsuite/23_containers/mdspan/submdspan/strided_slice_neg.cc: Move to...
* testsuite/23_containers/mdspan/submdspan/extent_slice_neg.cc: ...here
and handle rename.
* testsuite/23_containers/mdspan/submdspan/selections/testcases.h:
Replaced all occurences of strided_slice to extent_slice.
* testsuite/23_containers/mdspan/submdspan/subextents.cc: Likewise.
* testsuite/23_containers/mdspan/submdspan/subextents_neg.cc:
Likewise.
* testsuite/23_containers/mdspan/submdspan/submdspan_mapping.cc:
Likewise.
* testsuite/23_containers/mdspan/submdspan/submdspan_neg.cc: Likewise.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This patch implements the changes suggested in P3982R2 (and PL007 NB comment)
for C++26, but changing the strided_slice::extent to indicate number of
elements (extent) in the produced (output) mdspan, instead of input.
libstdc++-v3/ChangeLog:
* include/std/mdspan (__mdspan::__static_slice_extent)
(__mdspan::__dynamic_slice_extent): Return unmodified extent
value for strided_slice.
(__mdspan::__substrides_generic, __mdspan::__substrides_standardized):
Multipliy stride, if more than one element is requested.
(__mdspan::__canonical_range_slice): Define.
(__mdspan::__slice_cast): Use __canonical_range_slice for range_slice
and two elements tuples.
(__mdspan::__check_inrange_index): Define.
(__mdspan::__check_valid_slice): Validate if slice.offset +
(slice.extent - 1) * slice.stride fits into extent of given
dimension. Check stride if slice.extent > 1.
* testsuite/23_containers/mdspan/submdspan/canonical_slices.cc:
Add test for range_slice.
* testsuite/23_containers/mdspan/submdspan/canonical_slices_neg.cc:
Add tests validating new conditions.
* testsuite/23_containers/mdspan/submdspan/selections/testcases.h:
Adjusted for change of meaing of strided_slice::extent.
* testsuite/23_containers/mdspan/submdspan/subextents.cc:
Adjusted for change of meaing of strided_slice::extent. And expanded
range_slice tests.
* testsuite/23_containers/mdspan/submdspan/subextents_neg.cc:
Adjusted for change of meaing of strided_slice::extent.
* testsuite/23_containers/mdspan/submdspan/submdspan_neg.cc:
Adjust test for stride value.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This patch add a range_slice a class, and maps it to strided_slice
with the original meanning. This is usefull for benchmark, as effects
of strided_slice remain stable before and after the change.
libstdc++-v3/ChangeLog:
* src/c++23/std.cc.in (range_slice): Export.
* include/std/mdspan (range_slice, __mdspan::__is_range_slice):
Define.
(__mdspan::__slice_cast): Handle strided_slice.
* testsuite/23_containers/mdspan/submdspan/subextents.cc:
Sanity tests for range_slice.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This doesn't matter in practice, but strictly speaking the right value
for defining std::dynamic_format is 202603 not 202311 (which was the
macro value for the old name, std::runtime_format).
libstdc++-v3/ChangeLog:
* include/std/format (dynamic_format): Check new value for
feature test macro.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
The following patch attempts to implement
https://cplusplus.github.io/LWG/lwg-active.html#4537
I've also added tests for the returned type.
2026-04-01 Jakub Jelinek <jakub@redhat.com>
* include/std/meta (std::meta::__detail::__statically_sized): New
concept.
(std::meta::define_static_array): Change return type to auto. If
__statically_sized<_Rg>, return span with ranges::size(__r) as
second argument.
* g++.dg/reflect/define_static_array1.C (l): Another variable
with define_static_array test from array<int, 0>.
Add static assertions for types of the define_static_array results.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
In revision 698a6af5dc the _GLIBCXX_DEBUG code
for the Library Defect 438 has been removed as starting in C++11 the iterator
type is constrained through the _RequireInputIter requirement.
But the COW basic_string implementation used when _GLIBCXX_USE_CXX11_ABI=0 is
missing the _RequireInputIter constraint on a number of methods resulting in test
failures.
For the moment move the culprit __glibcxx_requires_valid_range call in the COW
basic_string implementation in a method where the iterator type has already been
checked.
libstdc++-v3/ChangeLog:
* include/bits/cow_string.h
(basic_string::replace(iterator, iterator, _InputIte, _InputIte)): Move
__glibcxx_requires_valid_range to...
(basic_string::_M_replace_dispatch(iterator, iterator, _InputIte,
_InputIte, __fase_type)): ...here.
* testsuite/21_strings/basic_string/debug/append_neg.cc: New test case.
* testsuite/21_strings/basic_string/debug/assign_neg.cc: New test case.
* testsuite/21_strings/basic_string/debug/construct_neg.cc: New test case.
* testsuite/21_strings/basic_string/debug/insert_neg.cc: New test case.
* testsuite/21_strings/basic_string/debug/replace_neg.cc: New test case.
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
These helpers were needed to work around GCC's historically strict
interpretation of friendship for hidden friends whereby they did not
inherit the friends of the containing class. But this has been relaxed
in r13-465 which granted hidden friends the same access as any other
member declaration, and <ranges> additions since then rely on this
relaxed interpretation. (Note that Clang also has this relaxed
interpretation, but MSVC / EDG seem to have the strict interpretation.)
This patch removes these now redundant member functions and inlines
their logic directly into the respective friend operators, making
things simpler and more consistent.
libstdc++-v3/ChangeLog:
* include/std/ranges (iota_view::_Sentinel): Remove _M_equal and
_M_distance_from. Inline logic into friend operators.
(basic_istream_view::_Iterator): Remove _M_at_end. Inline logic
into operator==.
(transform_view::_Sentinel): Remove __distance_from and __equal.
Inline logic into friend operators.
(join_view::_Sentinel): Remove __equal. Inline logic into operator==.
(lazy_split_view::_OuterIter): Remove __at_end. Inline logic into
operator==.
(split_view::_Sentinel): Remove _M_equal. Inline logic into operator==.
(elements_view::_Sentinel): Remove _M_equal and _M_distance_from.
Inline logic into friend operators.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Last week in Croydon we approved P3953R3 to rename std::runtime_format
for C++26. The rationale is that with compile-time std::format, the name
std::runtime_format doesn't make sense. It's std::dynamic_format now
instead.
libstdc++-v3/ChangeLog:
* include/bits/chrono_io.h (__formatter_chrono::_S_empty_fs)
(__formatter_chrono::_M_C_y_Y, __formatter_chrono::_M_D_x)
(__formatter_chrono::_M_F, __formatter_chrono::_M_subsecs)
(__formatter_chrono_info::_M_format_to): Use
_Dynamic_format_string instead of _Runtime_format_string.
* include/bits/version.def (format): Bump value.
* include/bits/version.h: Regenerate.
* include/std/format (_Runtime_format_string): Rename to
_Dynamic_format_string.
(runtime_format): Rename to dynamic_format.
* include/std/print (println): Adjust comment to refer to
dynamic_format instead of runtime_format.
* testsuite/std/format/runtime_format.cc: Move to...
* testsuite/std/format/dynamic_format.cc: ...here.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Last week in Croydon we approved P4052R0 to rename std::add_sat etc. for
C++26
libstdc++-v3/ChangeLog:
* include/bits/sat_arith.h (add_sat, sub_sat, mul_sat, div_sat)
(saturate_cast): Rename to saturating_xxx as per P4052R0.
* include/bits/version.def (saturation_arithmetic): Bump value.
* include/bits/version.h: Regenerate.
* testsuite/26_numerics/saturation/add.cc: Use new name.
* testsuite/26_numerics/saturation/cast.cc: Likewise.
* testsuite/26_numerics/saturation/div.cc: Likewise.
* testsuite/26_numerics/saturation/extended.cc: Likewise.
* testsuite/26_numerics/saturation/mul.cc: Likewise.
* testsuite/26_numerics/saturation/sub.cc: Likewise.
* testsuite/26_numerics/saturation/version.cc: Check for updated
value.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
The following patch attempts to implement another part of P3795R2,
in particular the addition of annotations to data_member_options
and handling it in data_member_spec/define_aggregate etc.
2026-03-31 Jakub Jelinek <jakub@redhat.com>
libstdc++-v3/
* include/std/meta (std::meta::data_member_options): Add annotations
member.
gcc/cp/
* reflect.cc (get_range_elts): If N is negative, just use the tree
as object to extract range from instead of finding Nth argument
of a call.
(eval_is_bit_field, eval_type_of, eval_size_of, eval_alignment_of,
eval_bit_size_of, eval_has_identifier, eval_identifier_of): Adjust
function comments from P3795R2.
(eval_display_string_of): Handle annotations in
REFLECT_DATA_MEMBER_SPEC.
(eval_annotations_of): Adjust function comments from P3795R2.
(eval_data_member_spec): Likewise. Read and diagnose annotations.
(eval_define_aggregate): Adjust function comments from P3795R2.
Create annotations.
(compare_reflections): Compare REFLECT_DATA_MEMBER_SPEC annotations.
* mangle.cc (write_reflection): Mangle REFLECT_DATA_MEMBER_SPEC
annotations.
gcc/testsuite/
* g++.dg/reflect/data_member_spec5.C: New test.
* g++.dg/reflect/data_member_spec6.C: New test.
* g++.dg/reflect/display_string_of1.C: Expect extra ", {}" before
closing paren for empty annotations, otherwise a list of annotations.
* g++.dg/reflect/u8display_string_of1.C: Likewise.
* g++.dg/reflect/define_aggregate9.C: New test.
* g++.dg/reflect/mangle1.C: Test mangling of REFLECT_DATA_MEMBER_SPEC
annotations.
Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
The following patch implements addition of std::meta::current_function,
std::meta::current_class, std::meta::current_namespace metafunctions
from P3795R2 - Miscellaneous Reflection Cleanup paper.
2026-03-31 Jakub Jelinek <jakub@redhat.com>
gcc/cp/
* metafns.gperf (enum metafn_code): Add METAFN_CURRENT_FUNCTION,
METAFN_CURRENT_CLASS and METAFN_CURRENT_NAMESPACE.
(enum metafn_kind): Add METAFN_KIND_INFO_VOID.
(current_function, current_class, current_namespace): New
metafunctions.
* pt.cc (value_dependent_expression_p): Make current_function(),
current_class() and current_namespace() calls dependent if they
are inside of template.
* reflect.cc (reflect_current_scope, eval_current_function,
eval_current_class, eval_current_namespace): New functions.
(eval_access_context_current): Use reflect_current_scope.
(process_metafunction): Handle METAFN_CURRENT_FUNCTION,
METAFN_CURRENT_CLASS and METAFN_CURRENT_NAMESPACE.
* metafns.h: Regenerate.
gcc/testsuite/
* g++.dg/reflect/current_function1.C: New test.
* g++.dg/reflect/current_function2.C: New test.
* g++.dg/reflect/current_class1.C: New test.
* g++.dg/reflect/current_class2.C: New test.
* g++.dg/reflect/current_namespace1.C: New test.
libstdc++-v3/
* include/std/meta (std::meta::current_function,
std::meta::current_class, std::meta::current_namespace): New
declarations.
* src/c++23/std.cc.in: Export those 3.
Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
This implements with P3936R1 Safer atomic_ref::address with
the bump to __cpp_lib_atomic_ref feture test macro.
libstdc++-v3/ChangeLog:
* include/bits/atomic_base.h (__atomic_ref_base::_Address_return_t):
Define.
(__atomic_ref_base::address): Change return type to _Address_return_t.
* include/bits/version.def (atomic_ref): Bump to 202603.
* include/bits/version.h: Regenerate.
* testsuite/29_atomics/atomic_ref/address.cc: Update check for
return type.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Unhappy about the old and new names, as a function type is not a function,
but ces't la vie.
2026-03-30 Jakub Jelinek <jakub@redhat.com>
gcc/cp/
* metafns.gperf (enum metafn_code): Remove
METAFN_HAS_ELLIPSIS_PARAMETER, add METAFN_IS_VARARG_FUNCTION.
(has_ellipsis_parameter): Remove.
(is_vararg_function): Add.
* reflect.cc (eval_has_ellipsis_parameter): Rename to ...
(eval_is_vararg_function): ... this. Adjust function comment.
(process_metafunction): Handle METAFN_IS_VARARG_FUNCTION
instead of METAFN_HAS_ELLIPSIS_PARAMETER.
* metafns.h: Regenerate.
gcc/testsuite/
* g++.dg/reflect/has_ellipsis_parameter1.C: Rename to ...
* g++.dg/reflect/is_vararg_function1.C: this. New test. Rename
has_ellipsis_parameter to is_vararg_function everywhere.
libstdc++-v3/
* include/std/meta (has_ellipsis_parameter): Rename to ...
(is_vararg_function): ... this. New declaration.
* src/c++23/std.cc.in: Remove std::meta::has_ellipsis_parameter
export, add std::meta::is_vararg_function export.
On a target that defaults to -mlong-double-64 -msse,
standard_abi_usable.cc and other tests fail to compile because of the
assert that rejects long double. As on ppc, we can trivially make
things work for -mlong-double-64.
for libstdc++-v3/ChangeLog
* include/experimental/bits/simd.h (__intrinsic_type): Accept
64-bit long doubles on x86 SSE.