<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Jul 10, 2026 at 11:20 AM Jonathan Wakely <<a href="mailto:jwakely@redhat.com">jwakely@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, 10 Jul 2026 at 08:04, Tomasz Kamiński <<a href="mailto:tkaminsk@redhat.com" target="_blank">tkaminsk@redhat.com</a>> wrote:<br>
><br>
> Add checks for bound being non-negative to _Tp&& __value and<br>
> piecewise_construct_t constructor. The later resolves LWG3772,<br>
> "repeat_view's piecewise constructor is missing Postconditions".<br>
><br>
> We use __detail::__is_signed_integer_like<_Bound> as the condition<br>
> for performing the check, to avoid checking it for unsigned integers<br>
> for which it is trivially met. As _Bound is constrained to either<br>
> unreachable_sentinel_t or integer-like, this gives equivalent behavior<br>
> to standard specified !same_as<_Bound, unreachable_sentinel_t>.<br>
><br>
> libstdc++-v3/ChangeLog:<br>
><br>
> * include/std/ranges (repeat_view::repeat_view): Assert that<br>
> __bound >= 0 consistently. Replace !same_as<unreachable_sentinel><br>
> with __is_signed_integer_like check.<br>
> ---<br>
> Testing on x86_64-linux. *repeat* test passed.<br>
> OK for trunk when all test passes?<br>
><br>
> libstdc++-v3/include/std/ranges | 14 +++++++++++---<br>
> 1 file changed, 11 insertions(+), 3 deletions(-)<br>
><br>
> diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges<br>
> index 39a50b03e45..ea69a6c8dee 100644<br>
> --- a/libstdc++-v3/include/std/ranges<br>
> +++ b/libstdc++-v3/include/std/ranges<br>
> @@ -7918,14 +7918,17 @@ namespace views::__adaptor<br>
> requires copy_constructible<_Tp><br>
> : _M_value(__value), _M_bound(__bound)<br>
> {<br>
> - if constexpr (!same_as<_Bound, unreachable_sentinel_t>)<br>
> + if constexpr (__detail::__is_signed_integer_like<_Bound>)<br>
> __glibcxx_assert(__bound >= 0);<br>
> }<br>
><br>
> constexpr explicit<br>
> repeat_view(_Tp&& __value, _Bound __bound = _Bound())<br>
> : _M_value(std::move(__value)), _M_bound(__bound)<br>
> - { }<br>
> + {<br>
> + if constexpr (__detail::__is_signed_integer_like<_Bound>)<br>
> + __glibcxx_assert(__bound >= 0);<br>
> + }<br>
><br>
> template<typename... _Args, typename... _BoundArgs><br>
> requires constructible_from<_Tp, _Args...><br>
> @@ -7936,7 +7939,12 @@ namespace views::__adaptor<br>
> tuple<_BoundArgs...> __bound_args = tuple<>{})<br>
> : _M_value(std::make_from_tuple<_Tp>(std::move(__args))),<br>
> _M_bound(std::make_from_tuple<_Bound>(std::move(__bound_args)))<br>
> - { }<br>
> + {<br>
> + // _GLIBCXX_RESOLVE_LIB_DEFECTS<br>
> + // 3772. repeat_view's piecewise constructor is missing Postconditions<br>
<br>
We don't need the comment because this is a C++23 feature and the LWG<br>
issue was resolved before publication of the C++23 standard. So this<br>
is just what the C++23 standard says, not a defect against C++23 that<br>
was resolved later.<br></blockquote><div>I forgot I am fixing issues from 2022. Thanks. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
OK for trunk and gcc-16 without the comment, thanks.<br>
<br>
<br>
> + if constexpr (__detail::__is_signed_integer_like<_Bound>)<br>
> + __glibcxx_assert(_M_bound >= 0);<br>
> + }<br>
><br>
> constexpr _Iterator<br>
> begin() const<br>
> --<br>
> 2.54.0<br>
><br>
<br>
</blockquote></div></div>