From 6af7e3f187ec32b498d4f80497bb4718040dcfb9 Mon Sep 17 00:00:00 2001 From: cpplearner Date: Tue, 17 May 2022 17:57:00 +0800 Subject: [PATCH 1/4] Temporarily disable `join_view` for non-`forward_range`s --- stl/inc/ranges | 8 ++++++++ tests/libcxx/usual_matrix.lst | 2 +- tests/std/tests/P0896R4_views_join/test.cpp | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/stl/inc/ranges b/stl/inc/ranges index cbb6a729bea..452a5878754 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -3068,6 +3068,14 @@ namespace ranges { requires view<_Vw> && input_range> class join_view : public _Join_view_base<_Vw> { // clang-format on + +#ifndef _USE_JOIN_VIEW_INPUT_RANGE + static_assert(forward_range<_Vw>, + "Using join_view with input-only ranges is temporarily disabled because of a bug that makes join_view " + "misbehave for certain ranges. See https://cplusplus.github.io/LWG/issue3698. You can define " + "_USE_JOIN_VIEW_INPUT_RANGE to suppress this diagnostic."); +#endif // _USE_JOIN_VIEW_INPUT_RANGE + private: template using _InnerRng = range_reference_t<_Maybe_const<_Const, _Vw>>; diff --git a/tests/libcxx/usual_matrix.lst b/tests/libcxx/usual_matrix.lst index 193320fdd4d..f80e837439c 100644 --- a/tests/libcxx/usual_matrix.lst +++ b/tests/libcxx/usual_matrix.lst @@ -4,7 +4,7 @@ RUNALL_INCLUDE ..\universal_prefix.lst RUNALL_CROSSLIST # TRANSITION, LLVM-53957: _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS belongs to llvm-project/libcxx/test/support/msvc_stdlib_force_include.h -PM_CL="/EHsc /MTd /std:c++latest /permissive- /FImsvc_stdlib_force_include.h /wd4643 /D_STL_CALL_ABORT_INSTEAD_OF_INVALID_PARAMETER /D_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS" +PM_CL="/EHsc /MTd /std:c++latest /permissive- /FImsvc_stdlib_force_include.h /wd4643 /D_STL_CALL_ABORT_INSTEAD_OF_INVALID_PARAMETER /D_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS /D_USE_JOIN_VIEW_INPUT_RANGE" RUNALL_CROSSLIST PM_CL="/analyze:autolog- /Zc:preprocessor" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing" diff --git a/tests/std/tests/P0896R4_views_join/test.cpp b/tests/std/tests/P0896R4_views_join/test.cpp index a52dfed7e57..bbc4dc03ba8 100644 --- a/tests/std/tests/P0896R4_views_join/test.cpp +++ b/tests/std/tests/P0896R4_views_join/test.cpp @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#define _USE_JOIN_VIEW_INPUT_RANGE + #include #include #include From c59ebdf7661dc3f6beb2ef3084949ff38da9d149 Mon Sep 17 00:00:00 2001 From: cpplearner Date: Wed, 18 May 2022 18:32:22 +0800 Subject: [PATCH 2/4] Reword --- stl/inc/ranges | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/ranges b/stl/inc/ranges index 452a5878754..4c3f9ec8893 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -3071,8 +3071,8 @@ namespace ranges { #ifndef _USE_JOIN_VIEW_INPUT_RANGE static_assert(forward_range<_Vw>, - "Using join_view with input-only ranges is temporarily disabled because of a bug that makes join_view " - "misbehave for certain ranges. See https://cplusplus.github.io/LWG/issue3698. You can define " + "Using join_view with input-only ranges is temporarily disabled because this can misbehave " + "for certain ranges. See https://cplusplus.github.io/LWG/issue3698. You can define " "_USE_JOIN_VIEW_INPUT_RANGE to suppress this diagnostic."); #endif // _USE_JOIN_VIEW_INPUT_RANGE From 7b2fd465717817dece2a63b9bf60dd19dd586841 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Sun, 22 May 2022 11:35:43 -0700 Subject: [PATCH 3/4] Clarify error message --- stl/inc/ranges | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/stl/inc/ranges b/stl/inc/ranges index 4c3f9ec8893..5c7ca4b1929 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -3070,10 +3070,15 @@ namespace ranges { // clang-format on #ifndef _USE_JOIN_VIEW_INPUT_RANGE - static_assert(forward_range<_Vw>, - "Using join_view with input-only ranges is temporarily disabled because this can misbehave " - "for certain ranges. See https://cplusplus.github.io/LWG/issue3698. You can define " - "_USE_JOIN_VIEW_INPUT_RANGE to suppress this diagnostic."); + static_assert(forward_range<_Vw> || borrowed_range<_Vw>, + "Due to a design flaw, join_view can misbehave " + "with some input-only ranges (see https://wg21.link/lwg3698). " + "We believe that WG21 will be unable to fix this problem without breaking ABI. " + "To minimize breakage when a fix is implemented, " + "we are temporarily disabling potentially problematic cases. " + "You can define _USE_JOIN_VIEW_INPUT_RANGE to suppress this diagnostic, " + "but be aware that you will almost certainly need to recompile " + "when we release a fix."); #endif // _USE_JOIN_VIEW_INPUT_RANGE private: From cd1a3a3cbd267cbc47e1228a175a635650b98863 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Sun, 22 May 2022 22:34:56 -0700 Subject: [PATCH 4/4] Back out broken borrowed_range change until I can think it through thoroughly. Co-authored-by: timsong-cpp --- stl/inc/ranges | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/ranges b/stl/inc/ranges index 5c7ca4b1929..3ae0270bd0e 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -3070,7 +3070,7 @@ namespace ranges { // clang-format on #ifndef _USE_JOIN_VIEW_INPUT_RANGE - static_assert(forward_range<_Vw> || borrowed_range<_Vw>, + static_assert(forward_range<_Vw>, "Due to a design flaw, join_view can misbehave " "with some input-only ranges (see https://wg21.link/lwg3698). " "We believe that WG21 will be unable to fix this problem without breaking ABI. "