From 16031cbf2bb1662f3b457e537d3e2d84a21adc7c Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 22 Jan 2022 15:29:18 -0500 Subject: [PATCH] [libc++] Fix LWG3557 "static_cast expression in convertible_to has the wrong operand" https://cplusplus.github.io/LWG/issue3557 I think the code change is unobservable, so we could just close this as "Nothing To Do" instead; but it seems appropriate to follow the Standard's wording here as closely as possible. Differential Revision: https://reviews.llvm.org/D117964 --- libcxx/docs/Status/Cxx2bIssues.csv | 2 +- libcxx/include/__concepts/convertible_to.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libcxx/docs/Status/Cxx2bIssues.csv b/libcxx/docs/Status/Cxx2bIssues.csv index 855a1f43a2a9..f949102e94b1 100644 --- a/libcxx/docs/Status/Cxx2bIssues.csv +++ b/libcxx/docs/Status/Cxx2bIssues.csv @@ -114,7 +114,7 @@ `3498 `__,"Inconsistent ``noexcept``-specifiers for ``basic_syncbuf``","October 2021","","" `3535 `__,"``join_view::iterator::iterator_category`` and ``::iterator_concept`` lie","October 2021","","","|ranges|" `3554 `__,"``chrono::parse`` needs ``const charT*`` and ``basic_string_view`` overloads","October 2021","","","|chrono|" -`3557 `__,"The ``static_cast`` expression in ``convertible_to`` has the wrong operand","October 2021","","" +`3557 `__,"The ``static_cast`` expression in ``convertible_to`` has the wrong operand","October 2021","|Complete|","14.0" `3559 `__,"Semantic requirements of ``sized_range`` is circular","October 2021","","","|ranges|" `3560 `__,"``ranges::equal`` and ``ranges::is_permutation`` should short-circuit for ``sized_ranges``","October 2021","","","|ranges|" `3561 `__,"Issue with internal counter in ``discard_block_engine``","October 2021","","" diff --git a/libcxx/include/__concepts/convertible_to.h b/libcxx/include/__concepts/convertible_to.h index ec68967106d5..795b0bd7494c 100644 --- a/libcxx/include/__concepts/convertible_to.h +++ b/libcxx/include/__concepts/convertible_to.h @@ -10,6 +10,7 @@ #define _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H #include <__config> +#include <__utility/declval.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -25,8 +26,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD template concept convertible_to = is_convertible_v<_From, _To> && - requires (add_rvalue_reference_t<_From> (&__f)()) { - static_cast<_To>(__f()); + requires { + static_cast<_To>(declval<_From>()); }; #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)