Skip to content

Conversation

H-G-Hristov
Copy link
Contributor

@H-G-Hristov H-G-Hristov requested a review from a team as a code owner August 24, 2025 14:12
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Aug 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 24, 2025

@llvm/pr-subscribers-libcxx

Author: Hristo Hristov (H-G-Hristov)

Changes

Fixes #104948


Full diff: https://github.com/llvm/llvm-project/pull/155169.diff

3 Files Affected:

  • (modified) libcxx/docs/Status/Cxx23Issues.csv (+1-1)
  • (modified) libcxx/include/__ranges/iota_view.h (+1-1)
  • (modified) libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp (+18)
diff --git a/libcxx/docs/Status/Cxx23Issues.csv b/libcxx/docs/Status/Cxx23Issues.csv
index 189f8452e0678..38571dabae463 100644
--- a/libcxx/docs/Status/Cxx23Issues.csv
+++ b/libcxx/docs/Status/Cxx23Issues.csv
@@ -143,7 +143,7 @@
 "`LWG3598 <https://wg21.link/LWG3598>`__","``system_category().default_error_condition(0)`` is underspecified","2022-02 (Virtual)","","",""
 "`LWG3601 <https://wg21.link/LWG3601>`__","common_iterator's postfix-proxy needs ``indirectly_readable`` ","2022-02 (Virtual)","","",""
 "`LWG3607 <https://wg21.link/LWG3607>`__","``contiguous_iterator`` should not be allowed to have custom ``iter_move`` and ``iter_swap`` behavior","2022-02 (Virtual)","|Nothing To Do|","",""
-"`LWG3610 <https://wg21.link/LWG3610>`__","``iota_view::size`` sometimes rejects integer-class types","2022-02 (Virtual)","","",""
+"`LWG3610 <https://wg21.link/LWG3610>`__","``iota_view::size`` sometimes rejects integer-class types","2022-02 (Virtual)","|Complete|","22",""
 "`LWG3612 <https://wg21.link/LWG3612>`__","Inconsistent pointer alignment in ``std::format`` ","2022-02 (Virtual)","|Complete|","14",""
 "`LWG3616 <https://wg21.link/LWG3616>`__","LWG 3498 seems to miss the non-member ``swap`` for ``basic_syncbuf`` ","2022-02 (Virtual)","|Complete|","18",""
 "`LWG3618 <https://wg21.link/LWG3618>`__","Unnecessary ``iter_move`` for ``transform_view::iterator`` ","2022-02 (Virtual)","|Complete|","19",""
diff --git a/libcxx/include/__ranges/iota_view.h b/libcxx/include/__ranges/iota_view.h
index 4b84585258b91..cf401a4665fcd 100644
--- a/libcxx/include/__ranges/iota_view.h
+++ b/libcxx/include/__ranges/iota_view.h
@@ -348,7 +348,7 @@ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> {
 
   _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
     requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) ||
-            (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
+            (__integer_like<_Start> && __integer_like<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
   {
     if constexpr (__integer_like<_Start> && __integer_like<_BoundSentinel>) {
       return (__value_ < 0)
diff --git a/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
index b894bc542be10..90afec2fba177 100644
--- a/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
@@ -16,8 +16,21 @@
 #include <ranges>
 
 #include "test_macros.h"
+#define TEST_HAS_NO_INT128
+#include "type_algorithms.h"
 #include "types.h"
 
+template <typename T>
+concept HasSize = requires(const T t) { t.size(); };
+
+struct CheckForSize {
+  template <class T>
+  constexpr void operator()() {
+    static_assert(HasSize<std::ranges::iota_view<T, int>>);
+    static_assert(HasSize<std::ranges::iota_view<T, T>>);
+  }
+};
+
 constexpr bool test() {
   // Both are integer like and both are less than zero.
   {
@@ -99,6 +112,11 @@ constexpr bool test() {
     assert(sz == 10);
   }
 
+  // LWG3610: `iota_view::size` sometimes rejects integer-class types
+  {
+    types::for_each(types::integer_types{}, CheckForSize{});
+  }
+
   return true;
 }
 

@frederick-vs-ja
Copy link
Contributor

I wondering that whether we treat __int128 as an extended integer type or an integer-class type. Also, I guess we should also cover _BitInt(N), see also #74161.

It seems to me that criteria for integer-class types are not very clear. CC @cjdb @ldionne.

@H-G-Hristov
Copy link
Contributor Author

I wondering that whether we treat __int128 as an extended integer type or an integer-class type. Also, I guess we should also cover _BitInt(N), see also #74161.

It seems to me that criteria for integer-class types are not very clear. CC @cjdb @ldionne.

integer-like types bigger than long long aren't supported by iota_view:

sizeof(_Int) <= sizeof(long long), "Found integer-like type that is bigger than largest integer like type.");

@frederick-vs-ja
Copy link
Contributor

I wondering that whether we treat __int128 as an extended integer type or an integer-class type. Also, I guess we should also cover _BitInt(N), see also #74161.
It seems to me that criteria for integer-class types are not very clear. CC @cjdb @ldionne.

integer-like types bigger than long long aren't supported by iota_view:

sizeof(_Int) <= sizeof(long long), "Found integer-like type that is bigger than largest integer like type.");

Oh... Then we also need to test using integer-class type as the _BoundSentinel type while the _Start type is an integer type.

(And if we want to properly support extended integer types, the restriction should be relaxed.)

@H-G-Hristov
Copy link
Contributor Author

H-G-Hristov commented Aug 25, 2025

I wondering that whether we treat __int128 as an extended integer type or an integer-class type. Also, I guess we should also cover _BitInt(N), see also #74161.
It seems to me that criteria for integer-class types are not very clear. CC @cjdb @ldionne.

integer-like types bigger than long long aren't supported by iota_view:

sizeof(_Int) <= sizeof(long long), "Found integer-like type that is bigger than largest integer like type.");

Oh... Then we also need to test using integer-class type as the _BoundSentinel type while the _Start type is an integer type.

(And if we want to properly support extended integer types, the restriction should be relaxed.)

For the record: there was mentioning of supporting __int128_t in the original PR:
https://reviews.llvm.org/D107396?id=366123#inline-1028560
https://reviews.llvm.org/D107396?id=365533#inline-1026761
Would this patch be the appropriate place also to try to do the update to support _int128_t? These comments make me think it should be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LWG3610: iota_view::size sometimes rejects integer-class types
4 participants