From 068f7c1f18c6549f7a673ea73136cb231dcc52f4 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 10:13:04 +0800 Subject: [PATCH 01/19] Workaround for wrong results of conditional operator --- stl/inc/type_traits | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 2aa95b03e48..33b77e368a7 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1179,9 +1179,33 @@ struct basic_common_reference {}; template _Ty _Returns_exactly() noexcept; // not defined +#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, GH-2581 +template +using _Cond_res_if_right = // N4810 [meta.trans.other]/2.4 + decltype(false ? _Returns_exactly<_Ty1>() : _Returns_exactly<_Ty2>()); + +template +struct _Cond_res_workaround {}; + +template +struct _Cond_res_workaround<_Ty1, _Ty2, void_t<_Cond_res_if_right<_Ty1, _Ty2>>> { + using _Uty = remove_cvref_t<_Ty1>; + using type = conditional_t< + conjunction_v>, is_scalar<_Uty>, + disjunction< + conjunction, is_rvalue_reference<_Ty2>>, + conjunction, is_lvalue_reference<_Ty2>>>>, + _Uty, + _Cond_res_if_right<_Ty1, _Ty2>>; +}; + +template +using _Cond_res = typename _Cond_res_workaround<_Ty1, _Ty2>::type; +#else // ^^^ workaround / no workaround vvv template using _Cond_res = // N4810 [meta.trans.other]/2.4 decltype(false ? _Returns_exactly<_Ty1>() : _Returns_exactly<_Ty2>()); +#endif template struct _Copy_cv_impl { From 92bf2bfd11e1e202c9bcafa56374c10f309bc307 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 10:17:14 +0800 Subject: [PATCH 02/19] Tests for GH-2581 --- .../env.lst | 4 ++ .../test.cpp | 42 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tests/std/tests/GH_002581_common_reference_workaround/env.lst create mode 100644 tests/std/tests/GH_002581_common_reference_workaround/test.cpp diff --git a/tests/std/tests/GH_002581_common_reference_workaround/env.lst b/tests/std/tests/GH_002581_common_reference_workaround/env.lst new file mode 100644 index 00000000000..351a8293d9d --- /dev/null +++ b/tests/std/tests/GH_002581_common_reference_workaround/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_20_matrix.lst diff --git a/tests/std/tests/GH_002581_common_reference_workaround/test.cpp b/tests/std/tests/GH_002581_common_reference_workaround/test.cpp new file mode 100644 index 00000000000..08306312ef3 --- /dev/null +++ b/tests/std/tests/GH_002581_common_reference_workaround/test.cpp @@ -0,0 +1,42 @@ +#include +#include + +using namespace std; + +struct Test {}; +enum Unscoped {}; +enum class Scoped {}; + +// Tests for raw pointers +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); + +// Tests for move_iterator specializations +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); + +int main() {} // COMPILE-ONLY From 77139c217a385a0e6e81e546d28028b572361929 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 11:11:36 +0800 Subject: [PATCH 03/19] clang-format (makes it harder to read at least for me...) --- stl/inc/type_traits | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 33b77e368a7..aca6c38703f 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1190,13 +1190,10 @@ struct _Cond_res_workaround {}; template struct _Cond_res_workaround<_Ty1, _Ty2, void_t<_Cond_res_if_right<_Ty1, _Ty2>>> { using _Uty = remove_cvref_t<_Ty1>; - using type = conditional_t< - conjunction_v>, is_scalar<_Uty>, - disjunction< - conjunction, is_rvalue_reference<_Ty2>>, - conjunction, is_lvalue_reference<_Ty2>>>>, - _Uty, - _Cond_res_if_right<_Ty1, _Ty2>>; + using type = conditional_t>, is_scalar<_Uty>, + disjunction, is_rvalue_reference<_Ty2>>, + conjunction, is_lvalue_reference<_Ty2>>>>, + _Uty, _Cond_res_if_right<_Ty1, _Ty2>>; }; template From 7f8fc67b7104e926b9ee7032a099c5cac5b7ff27 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 11:18:14 +0800 Subject: [PATCH 04/19] clang-format --- .../test.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/std/tests/GH_002581_common_reference_workaround/test.cpp b/tests/std/tests/GH_002581_common_reference_workaround/test.cpp index 08306312ef3..96e1a7770bf 100644 --- a/tests/std/tests/GH_002581_common_reference_workaround/test.cpp +++ b/tests/std/tests/GH_002581_common_reference_workaround/test.cpp @@ -18,10 +18,10 @@ static_assert(contiguous_iterator); static_assert(contiguous_iterator); static_assert(contiguous_iterator); static_assert(contiguous_iterator); -static_assert(contiguous_iterator); -static_assert(contiguous_iterator); -static_assert(contiguous_iterator); -static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); +static_assert(contiguous_iterator); // Tests for move_iterator specializations static_assert(input_iterator>); @@ -34,9 +34,9 @@ static_assert(input_iterator>); static_assert(input_iterator>); static_assert(input_iterator>); static_assert(input_iterator>); -static_assert(input_iterator>); -static_assert(input_iterator>); -static_assert(input_iterator>); -static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); +static_assert(input_iterator>); int main() {} // COMPILE-ONLY From 26731cc118a347013ad1a4b9a34e1ac13d2cc73c Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 11:42:11 +0800 Subject: [PATCH 05/19] Restrict test cases --- tests/std/tests/GH_002581_common_reference_workaround/env.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/GH_002581_common_reference_workaround/env.lst b/tests/std/tests/GH_002581_common_reference_workaround/env.lst index 351a8293d9d..7b6bcff4830 100644 --- a/tests/std/tests/GH_002581_common_reference_workaround/env.lst +++ b/tests/std/tests/GH_002581_common_reference_workaround/env.lst @@ -1,4 +1,4 @@ # Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -RUNALL_INCLUDE ..\usual_20_matrix.lst +RUNALL_INCLUDE ..\strict_concepts_20_matrix.lst From 56b3f8dd474d443d00f3d0b396b20250a857308a Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 12:14:43 +0800 Subject: [PATCH 06/19] Do test workaround for DevCom-876860 --- tests/libcxx/skipped_tests.txt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/libcxx/skipped_tests.txt b/tests/libcxx/skipped_tests.txt index 06fcd2cfd10..1532766ccc3 100644 --- a/tests/libcxx/skipped_tests.txt +++ b/tests/libcxx/skipped_tests.txt @@ -256,17 +256,6 @@ atomics\atomics.types.generic\copy_semantics_traits.pass.cpp # DevCom-409222 "Constructing rvalue reference from non-reference-related lvalue reference" utilities\meta\meta.unary\meta.unary.prop\is_constructible.pass.cpp -# DevCom-876860 "conditional operator errors" blocks readable. -concepts\concepts.lang\concept.common\common_with.compile.pass.cpp -concepts\concepts.lang\concept.commonref\common_reference.compile.pass.cpp -containers\views\span.cons\iterator_sentinel.pass.cpp -iterators\iterator.requirements\iterator.concepts\iterator.concept.bidir\bidirectional_iterator.compile.pass.cpp -iterators\iterator.requirements\iterator.concepts\iterator.concept.random.access\contiguous_iterator.compile.pass.cpp -iterators\iterator.requirements\iterator.concepts\iterator.concept.readable\indirectly_readable.compile.pass.cpp -iterators\iterator.requirements\iterator.concepts\iterator.concept.forward\forward_iterator.compile.pass.cpp -iterators\iterator.requirements\iterator.concepts\iterator.concept.input\input_iterator.compile.pass.cpp -iterators\iterator.requirements\iterator.concepts\iterator.concept.random.access\random_access_iterator.compile.pass.cpp - # VSO-1271673 "static analyzer doesn't know about short-circuiting" algorithms\alg.sorting\alg.sort\partial.sort\partial_sort.pass.cpp algorithms\alg.sorting\alg.sort\partial.sort\partial_sort_comp.pass.cpp From 5ac903ee1ee14a072d24eabbbbd43fec63ee8edb Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 12:15:14 +0800 Subject: [PATCH 07/19] Do test workaround for DevCom-876860 --- tests/libcxx/expected_results.txt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 86852033399..94b353adfeb 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -256,17 +256,6 @@ std/atomics/atomics.types.generic/copy_semantics_traits.pass.cpp FAIL # DevCom-409222 "Constructing rvalue reference from non-reference-related lvalue reference" std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp:0 FAIL -# DevCom-876860 "conditional operator errors" blocks readable. -std/concepts/concepts.lang/concept.common/common_with.compile.pass.cpp:0 FAIL -std/concepts/concepts.lang/concept.commonref/common_reference.compile.pass.cpp:0 FAIL -std/containers/views/span.cons/iterator_sentinel.pass.cpp:0 FAIL -std/iterators/iterator.requirements/iterator.concepts/iterator.concept.bidir/bidirectional_iterator.compile.pass.cpp:0 FAIL -std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp:0 FAIL -std/iterators/iterator.requirements/iterator.concepts/iterator.concept.readable/indirectly_readable.compile.pass.cpp:0 FAIL -std/iterators/iterator.requirements/iterator.concepts/iterator.concept.forward/forward_iterator.compile.pass.cpp:0 FAIL -std/iterators/iterator.requirements/iterator.concepts/iterator.concept.input/input_iterator.compile.pass.cpp:0 FAIL -std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/random_access_iterator.compile.pass.cpp:0 FAIL - # VSO-1271673 "static analyzer doesn't know about short-circuiting" std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp:0 FAIL std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp:0 FAIL From 8941793bcd562d0b2d9e06787820bcee61b5bd97 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 12:15:26 +0800 Subject: [PATCH 08/19] Change comment from GH-2581 to DevCom-876860 --- stl/inc/type_traits | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index aca6c38703f..afa15669b73 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1179,7 +1179,7 @@ struct basic_common_reference {}; template _Ty _Returns_exactly() noexcept; // not defined -#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, GH-2581 +#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-876860 template using _Cond_res_if_right = // N4810 [meta.trans.other]/2.4 decltype(false ? _Returns_exactly<_Ty1>() : _Returns_exactly<_Ty2>()); From d63837828b53d598b231e9d264ee66c0a29e6ff8 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 14:15:31 +0800 Subject: [PATCH 09/19] Add workaround for arrays --- stl/inc/type_traits | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index afa15669b73..f06744f489d 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1184,16 +1184,19 @@ template using _Cond_res_if_right = // N4810 [meta.trans.other]/2.4 decltype(false ? _Returns_exactly<_Ty1>() : _Returns_exactly<_Ty2>()); +template +using _Is_scalar_or_array = disjunction, is_array<_Ty>>; + template struct _Cond_res_workaround {}; template struct _Cond_res_workaround<_Ty1, _Ty2, void_t<_Cond_res_if_right<_Ty1, _Ty2>>> { using _Uty = remove_cvref_t<_Ty1>; - using type = conditional_t>, is_scalar<_Uty>, + using type = conditional_t>, _Is_scalar_or_array<_Uty>, disjunction, is_rvalue_reference<_Ty2>>, conjunction, is_lvalue_reference<_Ty2>>>>, - _Uty, _Cond_res_if_right<_Ty1, _Ty2>>; + decay_t<_Ty1>, _Cond_res_if_right<_Ty1, _Ty2>>; }; template From f29d2dff1d42c51a65704ba242a0eae3e095011c Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 15:34:33 +0800 Subject: [PATCH 10/19] Fix the wrong fix, relying on _Copy_cv --- stl/inc/type_traits | 56 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index f06744f489d..0dd79bb412c 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1179,34 +1179,6 @@ struct basic_common_reference {}; template _Ty _Returns_exactly() noexcept; // not defined -#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-876860 -template -using _Cond_res_if_right = // N4810 [meta.trans.other]/2.4 - decltype(false ? _Returns_exactly<_Ty1>() : _Returns_exactly<_Ty2>()); - -template -using _Is_scalar_or_array = disjunction, is_array<_Ty>>; - -template -struct _Cond_res_workaround {}; - -template -struct _Cond_res_workaround<_Ty1, _Ty2, void_t<_Cond_res_if_right<_Ty1, _Ty2>>> { - using _Uty = remove_cvref_t<_Ty1>; - using type = conditional_t>, _Is_scalar_or_array<_Uty>, - disjunction, is_rvalue_reference<_Ty2>>, - conjunction, is_lvalue_reference<_Ty2>>>>, - decay_t<_Ty1>, _Cond_res_if_right<_Ty1, _Ty2>>; -}; - -template -using _Cond_res = typename _Cond_res_workaround<_Ty1, _Ty2>::type; -#else // ^^^ workaround / no workaround vvv -template -using _Cond_res = // N4810 [meta.trans.other]/2.4 - decltype(false ? _Returns_exactly<_Ty1>() : _Returns_exactly<_Ty2>()); -#endif - template struct _Copy_cv_impl { template @@ -1247,6 +1219,34 @@ struct _Add_qualifiers<_Ty1&&> { using _Apply = add_rvalue_reference_t<_Copy_cv<_Ty1, _Ty2>>; }; +#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-876860 +template +using _Cond_res_if_right = // N4810 [meta.trans.other]/2.4 + decltype(false ? _Returns_exactly<_Ty1>() : _Returns_exactly<_Ty2>()); + +template +using _Is_scalar_or_array = disjunction, is_array<_Ty>>; + +template +struct _Cond_res_workaround {}; + +template +struct _Cond_res_workaround<_Ty1, _Ty2, void_t<_Cond_res_if_right<_Ty1, _Ty2>>> { + using _Uty = remove_cvref_t<_Ty1>; + using type = conditional_t>, _Is_scalar_or_array<_Uty>, + disjunction, is_rvalue_reference<_Ty2>>, + conjunction, is_lvalue_reference<_Ty2>>>>, + decay_t<_Copy_cv, remove_reference_t<_Ty2>>>, _Cond_res_if_right<_Ty1, _Ty2>>; +}; + +template +using _Cond_res = typename _Cond_res_workaround<_Ty1, _Ty2>::type; +#else // ^^^ workaround / no workaround vvv +template +using _Cond_res = // N4810 [meta.trans.other]/2.4 + decltype(false ? _Returns_exactly<_Ty1>() : _Returns_exactly<_Ty2>()); +#endif + template struct common_reference; From 1b7c0a2f298d9824a1ff9d83cf26d565ebb11d74 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 17:49:26 +0800 Subject: [PATCH 11/19] Workaround for DevCom-1627396 --- stl/inc/type_traits | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 0dd79bb412c..6e9fb33fd53 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -323,6 +323,24 @@ _INLINE_VAR constexpr bool is_fundamental_v = is_arithmetic_v<_Ty> || is_void_v< template struct is_fundamental : bool_constant> {}; // determine whether _Ty is a fundamental type +#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-1627396 +template +_INLINE_VAR constexpr bool _Is_convertible_vref = false; + +template +_INLINE_VAR constexpr bool _Is_convertible_vref = true; + +template +_INLINE_VAR constexpr bool _Is_convertible_vref = true; + +template +struct is_convertible : bool_constant<__is_convertible_to(_From, _To) || _Is_convertible_vref<_From, _To>> { + // determine whether _From is convertible to _To +}; + +template +_INLINE_VAR constexpr bool is_convertible_v = __is_convertible_to(_From, _To) || _Is_convertible_vref<_From, _To>; +#else // ^^^ workaround / no workaround vvv template struct is_convertible : bool_constant<__is_convertible_to(_From, _To)> { // determine whether _From is convertible to _To @@ -330,6 +348,7 @@ struct is_convertible : bool_constant<__is_convertible_to(_From, _To)> { template _INLINE_VAR constexpr bool is_convertible_v = __is_convertible_to(_From, _To); +#endif template struct is_enum : bool_constant<__is_enum(_Ty)> {}; // determine whether _Ty is an enumerated type From 913f19a7d53f617574f7524cefb201149772bca2 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 17:54:24 +0800 Subject: [PATCH 12/19] Workaround for DevCom-1627396 --- stl/inc/concepts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stl/inc/concepts b/stl/inc/concepts index 110177a48af..ddcbf4d00e9 100644 --- a/stl/inc/concepts +++ b/stl/inc/concepts @@ -40,7 +40,11 @@ concept derived_from = __is_base_of(_Base, _Derived) && __is_convertible_to(const volatile _Derived*, const volatile _Base*); template +#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-1627396 +concept convertible_to = is_convertible_v<_From, _To> +#else // ^^^ workaround / no workaround vvv concept convertible_to = __is_convertible_to(_From, _To) +#endif && requires { static_cast<_To>(_STD declval<_From>()); }; From af4a819ce2728dafa185488e451bf60c40ba214c Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 17:59:06 +0800 Subject: [PATCH 13/19] Add missing banner --- tests/std/tests/GH_002581_common_reference_workaround/test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/std/tests/GH_002581_common_reference_workaround/test.cpp b/tests/std/tests/GH_002581_common_reference_workaround/test.cpp index 96e1a7770bf..1fe3ffe140e 100644 --- a/tests/std/tests/GH_002581_common_reference_workaround/test.cpp +++ b/tests/std/tests/GH_002581_common_reference_workaround/test.cpp @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + #include #include From 513751cc13e1e895bd3eaf46aa4b8cde85121f6c Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 17:59:45 +0800 Subject: [PATCH 14/19] Add GH_002581_common_reference_workaround to list --- tests/std/test.lst | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/std/test.lst b/tests/std/test.lst index af4d747a46e..e51161106e3 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -191,6 +191,7 @@ tests\GH_002030_asan_annotate_vector tests\GH_002039_byte_is_not_trivially_swappable tests\GH_002058_debug_iterator_race tests\GH_002120_streambuf_seekpos_and_seekoff +tests\GH_002581_common_reference_workaround tests\LWG2597_complex_branch_cut tests\LWG3018_shared_ptr_function tests\LWG3146_excessive_unwrapping_ref_cref From 0e484b28a8e4adab616da3a31c81b15f1a6a82c2 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 18:08:53 +0800 Subject: [PATCH 15/19] Make workaround less silly --- stl/inc/type_traits | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 6e9fb33fd53..0d8dae269a3 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -323,24 +323,6 @@ _INLINE_VAR constexpr bool is_fundamental_v = is_arithmetic_v<_Ty> || is_void_v< template struct is_fundamental : bool_constant> {}; // determine whether _Ty is a fundamental type -#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-1627396 -template -_INLINE_VAR constexpr bool _Is_convertible_vref = false; - -template -_INLINE_VAR constexpr bool _Is_convertible_vref = true; - -template -_INLINE_VAR constexpr bool _Is_convertible_vref = true; - -template -struct is_convertible : bool_constant<__is_convertible_to(_From, _To) || _Is_convertible_vref<_From, _To>> { - // determine whether _From is convertible to _To -}; - -template -_INLINE_VAR constexpr bool is_convertible_v = __is_convertible_to(_From, _To) || _Is_convertible_vref<_From, _To>; -#else // ^^^ workaround / no workaround vvv template struct is_convertible : bool_constant<__is_convertible_to(_From, _To)> { // determine whether _From is convertible to _To @@ -348,7 +330,20 @@ struct is_convertible : bool_constant<__is_convertible_to(_From, _To)> { template _INLINE_VAR constexpr bool is_convertible_v = __is_convertible_to(_From, _To); -#endif + +#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-1627396 +template +struct is_convertible : true_type {}; + +template +struct is_convertible : true_type {}; + +template +_INLINE_VAR constexpr bool is_convertible_v = true; + +template +_INLINE_VAR constexpr bool is_convertible_v = true; +#endif // ^^^ workaround template struct is_enum : bool_constant<__is_enum(_Ty)> {}; // determine whether _Ty is an enumerated type From 60e62decb52670a88fd8a1adb9414882244ec3f0 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 18:59:56 +0800 Subject: [PATCH 16/19] Workaround is needed in more cases --- stl/inc/type_traits | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 0d8dae269a3..f6de219e4ca 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -332,15 +332,27 @@ template _INLINE_VAR constexpr bool is_convertible_v = __is_convertible_to(_From, _To); #if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-1627396 +template +struct is_convertible<_Ty&, volatile _Ty&> : true_type {}; + template struct is_convertible : true_type {}; +template +struct is_convertible<_Ty&, const volatile _Ty&> : true_type {}; + template struct is_convertible : true_type {}; +template +_INLINE_VAR constexpr bool is_convertible_v<_Ty&, volatile _Ty&> = true; + template _INLINE_VAR constexpr bool is_convertible_v = true; +template +_INLINE_VAR constexpr bool is_convertible_v<_Ty&, const volatile _Ty&> = true; + template _INLINE_VAR constexpr bool is_convertible_v = true; #endif // ^^^ workaround From 6e129e84a1bae9f7735c16b58f716d25505d3998 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 19:28:10 +0800 Subject: [PATCH 17/19] Do test workaround for DevCom-1627396 --- tests/libcxx/skipped_tests.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/libcxx/skipped_tests.txt b/tests/libcxx/skipped_tests.txt index 1532766ccc3..8dcb80e5609 100644 --- a/tests/libcxx/skipped_tests.txt +++ b/tests/libcxx/skipped_tests.txt @@ -273,9 +273,6 @@ utilities\utility\pairs\pairs.spec\three_way_comparison.pass.cpp # DevCom-1626727: bogus "failure was caused by a conversion from void* to a pointer-to-object type" for conversion to void algorithms\robust_re_difference_type.compile.pass.cpp -# DevCom-1627396: C1XX's __is_convertible_to intrinsic mis-handles volatile array lvalues -concepts\concepts.lang\concept.swappable\swappable_with.compile.pass.cpp - # DevCom-1628714: C1XX refuses nullptr_t == reference-to-function in a requires expression concepts\concepts.compare\concept.equalitycomparable\equality_comparable_with.compile.pass.cpp From 5821ada310b35c8a646a19c3488c1a11beb02133 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 25 Feb 2022 19:28:30 +0800 Subject: [PATCH 18/19] Do test workaround for DevCom-1627396 --- tests/libcxx/expected_results.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 94b353adfeb..8c21921d80f 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -273,9 +273,6 @@ std/utilities/utility/pairs/pairs.spec/three_way_comparison.pass.cpp:0 FAIL # DevCom-1626727: bogus "failure was caused by a conversion from void* to a pointer-to-object type" for conversion to void std/algorithms/robust_re_difference_type.compile.pass.cpp:0 FAIL -# DevCom-1627396: C1XX's __is_convertible_to intrinsic mis-handles volatile array lvalues -std/concepts/concepts.lang/concept.swappable/swappable_with.compile.pass.cpp:0 FAIL - # DevCom-1628714: C1XX refuses nullptr_t == reference-to-function in a requires expression std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp:0 FAIL From 0783bb49bb5ebe6e25cf440d693f2ed9d62e8d4e Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 28 Feb 2022 19:00:24 -0800 Subject: [PATCH 19/19] Code review feedback. --- stl/inc/concepts | 2 +- stl/inc/type_traits | 2 +- .../{test.cpp => test.compile.pass.cpp} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename tests/std/tests/GH_002581_common_reference_workaround/{test.cpp => test.compile.pass.cpp} (100%) diff --git a/stl/inc/concepts b/stl/inc/concepts index ddcbf4d00e9..550d9440404 100644 --- a/stl/inc/concepts +++ b/stl/inc/concepts @@ -44,7 +44,7 @@ template concept convertible_to = is_convertible_v<_From, _To> #else // ^^^ workaround / no workaround vvv concept convertible_to = __is_convertible_to(_From, _To) -#endif +#endif // ^^^ no workaround ^^^ && requires { static_cast<_To>(_STD declval<_From>()); }; diff --git a/stl/inc/type_traits b/stl/inc/type_traits index f6de219e4ca..79c30c763f1 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1271,7 +1271,7 @@ using _Cond_res = typename _Cond_res_workaround<_Ty1, _Ty2>::type; template using _Cond_res = // N4810 [meta.trans.other]/2.4 decltype(false ? _Returns_exactly<_Ty1>() : _Returns_exactly<_Ty2>()); -#endif +#endif // ^^^ no workaround ^^^ template struct common_reference; diff --git a/tests/std/tests/GH_002581_common_reference_workaround/test.cpp b/tests/std/tests/GH_002581_common_reference_workaround/test.compile.pass.cpp similarity index 100% rename from tests/std/tests/GH_002581_common_reference_workaround/test.cpp rename to tests/std/tests/GH_002581_common_reference_workaround/test.compile.pass.cpp