]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add [[no_unique_address]] to repeat_view::_M_value [PR121402]
authorPatrick Palka <ppalka@redhat.com>
Wed, 18 Feb 2026 15:13:51 +0000 (10:13 -0500)
committerPatrick Palka <ppalka@redhat.com>
Wed, 18 Feb 2026 15:13:51 +0000 (10:13 -0500)
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 <jwakely@redhat.com>
libstdc++-v3/include/std/ranges
libstdc++-v3/testsuite/std/ranges/adaptors/sizeof.cc

index 8365bed17a6ec5b4da4dc9d7b54580923b978d5f..2cc17eb0f0741b33cdc2e070a2bd15b66d3536a0 100644 (file)
@@ -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;
index 0a84b0f1dcbe85d0bfbde511095b5b485bb540ef..45f53c783ec175b8e079a6c04e44c12fe8642f3a 100644 (file)
@@ -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