https://gcc.gnu.org/g:8ba1e2077f2827e7c3528b28c98d69606e284d1b
commit r16-7570-g8ba1e2077f2827e7c3528b28c98d69606e284d1b Author: Patrick Palka <[email protected]> Date: Wed Feb 18 10:13:51 2026 -0500 libstdc++: Add [[no_unique_address]] to repeat_view::_M_value [PR121402] PR libstdc++/121402 libstdc++-v3/ChangeLog: * include/std/ranges (repeat_view::_M_value): Add [[no_unique_address]]. * testsuite/std/ranges/adaptors/sizeof.cc [__cpp_lib_ranges_repeat]: New test. Reviewed-by: Jonathan Wakely <[email protected]> Diff: --- libstdc++-v3/include/std/ranges | 2 +- libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 8365bed17a6e..2cc17eb0f074 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -7874,7 +7874,7 @@ namespace views::__adaptor && (__detail::__is_integer_like<_Bound> || same_as<_Bound, unreachable_sentinel_t>) class repeat_view : public view_interface<repeat_view<_Tp, _Bound>> { - __detail::__box<_Tp> _M_value; + [[no_unique_address]] __detail::__box<_Tp> _M_value; [[no_unique_address]] _Bound _M_bound = _Bound(); class _Iterator; diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc index 0a84b0f1dcbe..45f53c783ec1 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc @@ -22,6 +22,8 @@ namespace ranges = std::ranges; +struct Empty { }; + auto pred_f(int x) { return x%2 == 0; }; auto pred_l = [] (int x) { return x%2 == 0; }; @@ -53,3 +55,7 @@ static_assert #if __cpp_lib_ranges_slide static_assert(sizeof(ranges::slide_view<V>) == 3*ptr); #endif + +#if __cpp_lib_ranges_repeat +static_assert(sizeof(ranges::repeat_view<Empty, size_t>) == 1*ptr); +#endif
