Conversation
Overload for operator- in ADT iterator is now constrained with concept BaseT::IsRandomAccess. Patch by Jonathan Wakely. Fixes llvm#139072.
|
@llvm/pr-subscribers-llvm-adt Author: Vedran Miletić (vedranmiletic) ChangesOverload for operator- in ADT iterator is now constrained with concept BaseT::IsRandomAccess. Patch by Jonathan Wakely. Fixes #139072. Full diff: https://github.com/llvm/llvm-project/pull/169772.diff 1 Files Affected:
diff --git a/llvm/include/llvm/ADT/iterator.h b/llvm/include/llvm/ADT/iterator.h
index 6f0c42fe08bec..f55f9d4a3e7f2 100644
--- a/llvm/include/llvm/ADT/iterator.h
+++ b/llvm/include/llvm/ADT/iterator.h
@@ -267,7 +267,11 @@ class iterator_adaptor_base
return *static_cast<DerivedT *>(this);
}
using BaseT::operator-;
- difference_type operator-(const DerivedT &RHS) const {
+ difference_type operator-(const DerivedT &RHS) const
+#ifdef __cpp_concepts
+ requires(bool(BaseT::IsRandomAccess))
+#endif
+ {
static_assert(
BaseT::IsRandomAccess,
"The '-' operator is only defined for random access iterators.");
|
jwakely
left a comment
There was a problem hiding this comment.
As noted at #139072 (comment) there are other operators which should really be constrained similarly. So this fixes the immediate issue, but there are still latent bugs that might cause similar errors later.
But they could be fixed later, if needed. |
|
Please update the description of the PR with a description of the problem you are trying to fix, I had to find this comment to understand the context. Thanks |
Co-authored-by: A. Jiang <de34@live.cn>
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Hope it is better now. |
Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
|
Can someone merge this for me? I don't have commit access. |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/35481 Here is the relevant piece of the build log for the reference |
|
Thanks! |
Building LLVM with CMAKE_CXX_STANDARD set to 20 fails since the iterator facade is not fully compatible with C++20. To make it compatible, specific operator overloads have to be constrained. Overload for operator- in ADT iterator is now constrained with concept BaseT::IsRandomAccess. Patch by Jonathan Wakely. Fixes llvm#139072. --------- Co-authored-by: A. Jiang <de34@live.cn> Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
This reverts commit a666d1f.
Integrate llvm/llvm-project@c0f4a8a Existing local reverts carried forward: * Local revert of llvm/llvm-project#169614 due to llvm/llvm-project#172932. Also adds a revert for a commit that breaks the MSVC build: * Local revert of llvm/llvm-project#169772. This can be dropped after llvm/llvm-project#173495. Signed-off-by: Jorn Tuyls <jorn.tuyls@gmail.com>
Fixes an MSCV build issue after the C++20 fix in #169772. See the [failure log](https://productionresultssa1.blob.core.windows.net/actions-results/604d315e-edbd-401f-9a85-9ec5fcbc4996/workflow-job-run-99b94847-47a4-5b95-9933-44db3e32a2a7/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-12-24T11%3A16%3A19Z&sig=3leOtxGMlJmAMzOCtakzD8%2FOQCXF2HfflooR%2Bm%2Bt7Ng%3D&ske=2025-12-24T21%3A53%3A06Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-12-24T09%3A53%3A06Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-11-05&sp=r&spr=https&sr=b&st=2025-12-24T11%3A06%3A14Z&sv=2025-11-05) in the IREE downstream project. Making IsRandomAccess, IsBidirectional public ensures that they are always accessible, avoiding the access-related SFINAE ambiguity that causes different compilers to handle this differently. The build is passing after this change: https://github.com/iree-org/iree/actions/runs/20485132054/job/58865989220?pr=22979
Fixes an MSCV build issue after the C++20 fix in llvm/llvm-project#169772. See the [failure log](https://productionresultssa1.blob.core.windows.net/actions-results/604d315e-edbd-401f-9a85-9ec5fcbc4996/workflow-job-run-99b94847-47a4-5b95-9933-44db3e32a2a7/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-12-24T11%3A16%3A19Z&sig=3leOtxGMlJmAMzOCtakzD8%2FOQCXF2HfflooR%2Bm%2Bt7Ng%3D&ske=2025-12-24T21%3A53%3A06Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-12-24T09%3A53%3A06Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-11-05&sp=r&spr=https&sr=b&st=2025-12-24T11%3A06%3A14Z&sv=2025-11-05) in the IREE downstream project. Making IsRandomAccess, IsBidirectional public ensures that they are always accessible, avoiding the access-related SFINAE ambiguity that causes different compilers to handle this differently. The build is passing after this change: https://github.com/iree-org/iree/actions/runs/20485132054/job/58865989220?pr=22979
Integrate llvm/llvm-project@75a0347 Removes a revert: * Local revert of llvm/llvm-project#169772 as the fix in llvm/llvm-project#173495 got merged. Existing local reverts carried forward: * Local revert of llvm/llvm-project#169614 due to llvm/llvm-project#172932. Signed-off-by: Jorn Tuyls <jorn.tuyls@gmail.com>
Building LLVM with CMAKE_CXX_STANDARD set to 20 fails since the iterator facade is not fully compatible with C++20. To make it compatible, specific operator overloads have to be constrained. Overload for operator- in ADT iterator is now constrained with concept BaseT::IsRandomAccess. Patch by Jonathan Wakely. Fixes llvm#139072. --------- Co-authored-by: A. Jiang <de34@live.cn> Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
Fixes an MSCV build issue after the C++20 fix in llvm#169772. See the [failure log](https://productionresultssa1.blob.core.windows.net/actions-results/604d315e-edbd-401f-9a85-9ec5fcbc4996/workflow-job-run-99b94847-47a4-5b95-9933-44db3e32a2a7/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-12-24T11%3A16%3A19Z&sig=3leOtxGMlJmAMzOCtakzD8%2FOQCXF2HfflooR%2Bm%2Bt7Ng%3D&ske=2025-12-24T21%3A53%3A06Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-12-24T09%3A53%3A06Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-11-05&sp=r&spr=https&sr=b&st=2025-12-24T11%3A06%3A14Z&sv=2025-11-05) in the IREE downstream project. Making IsRandomAccess, IsBidirectional public ensures that they are always accessible, avoiding the access-related SFINAE ambiguity that causes different compilers to handle this differently. The build is passing after this change: https://github.com/iree-org/iree/actions/runs/20485132054/job/58865989220?pr=22979
Fixes an MSCV build issue after the C++20 fix in llvm/llvm-project#169772. See the [failure log](https://productionresultssa1.blob.core.windows.net/actions-results/604d315e-edbd-401f-9a85-9ec5fcbc4996/workflow-job-run-99b94847-47a4-5b95-9933-44db3e32a2a7/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-12-24T11%3A16%3A19Z&sig=3leOtxGMlJmAMzOCtakzD8%2FOQCXF2HfflooR%2Bm%2Bt7Ng%3D&ske=2025-12-24T21%3A53%3A06Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-12-24T09%3A53%3A06Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-11-05&sp=r&spr=https&sr=b&st=2025-12-24T11%3A06%3A14Z&sv=2025-11-05) in the IREE downstream project. Making IsRandomAccess, IsBidirectional public ensures that they are always accessible, avoiding the access-related SFINAE ambiguity that causes different compilers to handle this differently. The build is passing after this change: https://github.com/iree-org/iree/actions/runs/20485132054/job/58865989220?pr=22979
Fixes an MSCV build issue after the C++20 fix in llvm/llvm-project#169772. See the [failure log](https://productionresultssa1.blob.core.windows.net/actions-results/604d315e-edbd-401f-9a85-9ec5fcbc4996/workflow-job-run-99b94847-47a4-5b95-9933-44db3e32a2a7/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-12-24T11%3A16%3A19Z&sig=3leOtxGMlJmAMzOCtakzD8%2FOQCXF2HfflooR%2Bm%2Bt7Ng%3D&ske=2025-12-24T21%3A53%3A06Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-12-24T09%3A53%3A06Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-11-05&sp=r&spr=https&sr=b&st=2025-12-24T11%3A06%3A14Z&sv=2025-11-05) in the IREE downstream project. Making IsRandomAccess, IsBidirectional public ensures that they are always accessible, avoiding the access-related SFINAE ambiguity that causes different compilers to handle this differently. The build is passing after this change: https://github.com/iree-org/iree/actions/runs/20485132054/job/58865989220?pr=22979 (cherry picked from commit 75a0347)
Integrate llvm/llvm-project@c0f4a8a Existing local reverts carried forward: * Local revert of llvm/llvm-project#169614 due to llvm/llvm-project#172932. Also adds a revert for a commit that breaks the MSVC build: * Local revert of llvm/llvm-project#169772. This can be dropped after llvm/llvm-project#173495. Signed-off-by: Jorn Tuyls <jorn.tuyls@gmail.com> Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
Integrate llvm/llvm-project@75a0347 Removes a revert: * Local revert of llvm/llvm-project#169772 as the fix in llvm/llvm-project#173495 got merged. Existing local reverts carried forward: * Local revert of llvm/llvm-project#169614 due to llvm/llvm-project#172932. Signed-off-by: Jorn Tuyls <jorn.tuyls@gmail.com> Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
Building LLVM with CMAKE_CXX_STANDARD set to 20 fails since the iterator facade is not fully compatible with C++20. To make it compatible, specific operator overloads have to be constrained.
Overload for operator- in ADT iterator is now constrained with concept BaseT::IsRandomAccess.
Patch by Jonathan Wakely.
Fixes #139072.