On Wed, 18 Feb 2026 at 14:50, Patrick Palka <[email protected]> wrote:
>
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
OK thanks
>
> -- >8 --
>
> 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.
> ---
> 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
> --
> 2.53.0.144.g73fd77805f
>