https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111948

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-10-24

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This patch makes the testcase compile, but I still think it's a compiler bug
not a library bug:

--- a/libstdc++-v3/include/bits/ranges_util.h
+++ b/libstdc++-v3/include/bits/ranges_util.h
@@ -267,13 +267,21 @@ namespace ranges
       using __size_type
        = __detail::__make_unsigned_like_t<iter_difference_t<_It>>;

-      template<typename, bool = _S_store_size>
+      template<typename _Tp, bool = _S_store_size>
        struct _Size
-       { };
+       {
+         [[__gnu__::__always_inline__]]
+         constexpr _Size(_Tp) { }
+       };

       template<typename _Tp>
        struct _Size<_Tp, true>
-       { _Tp _M_size; };
+       {
+         [[__gnu__::__always_inline__]]
+         constexpr _Size(_Tp __s) : _M_size(__s) { }
+
+         _Tp _M_size;
+       };

       [[no_unique_address]] _Size<__size_type> _M_size = {};

@@ -294,11 +302,8 @@ namespace ranges
       noexcept(is_nothrow_constructible_v<_It, decltype(__i)>
               && is_nothrow_constructible_v<_Sent, _Sent&>)
        requires (_Kind == subrange_kind::sized)
-      : _M_begin(std::move(__i)), _M_end(__s)
-      {
-       if constexpr (_S_store_size)
-         _M_size._M_size = __n;
-      }
+      : _M_begin(std::move(__i)), _M_end(__s), _M_size(__n)
+      { }

       template<__detail::__different_from<subrange> _Rng>
        requires borrowed_range<_Rng>

Reply via email to