[libcxx-commits] [libcxx] [libc++] LWG4511: Inconsistency between the deduction guide of `std::mdspan` taking `(data_handle_type, mapping_type, accessor_type)` and the corresponding constructor (PR #191950)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 13 23:01:02 PDT 2026


https://github.com/eiytoq updated https://github.com/llvm/llvm-project/pull/191950

>From 587e34c5a1a3a7f8025b755343c25b3ddca8c691 Mon Sep 17 00:00:00 2001
From: eiytoq <eiytoq at outlook.com>
Date: Tue, 14 Apr 2026 13:14:23 +0800
Subject: [PATCH 1/2] fix

---
 libcxx/docs/Status/Cxx2cIssues.csv                         | 2 +-
 libcxx/include/__mdspan/mdspan.h                           | 2 +-
 libcxx/include/mdspan                                      | 2 +-
 .../std/containers/views/mdspan/mdspan/deduction.pass.cpp  | 7 ++++++-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libcxx/docs/Status/Cxx2cIssues.csv b/libcxx/docs/Status/Cxx2cIssues.csv
index a4afad4efa884..381ef0bc72de3 100644
--- a/libcxx/docs/Status/Cxx2cIssues.csv
+++ b/libcxx/docs/Status/Cxx2cIssues.csv
@@ -315,7 +315,7 @@
 "`LWG4504 <https://wg21.link/LWG4504>`__","Wording problem in ``{simple_}counting_scope``","2026-03 (Croydon)","","","`#189857 <https://github.com/llvm/llvm-project/issues/189857>`__",""
 "`LWG4506 <https://wg21.link/LWG4506>`__","``source_location`` is explicitly unspecified if is constexpr or not","2026-03 (Croydon)","","","`#189858 <https://github.com/llvm/llvm-project/issues/189858>`__",""
 "`LWG4510 <https://wg21.link/LWG4510>`__","Ambiguity of ``std::ranges::advance`` and ``std::ranges::next`` when the difference type is also a sentinel type","2026-03 (Croydon)","","","`#189859 <https://github.com/llvm/llvm-project/issues/189859>`__",""
-"`LWG4511 <https://wg21.link/LWG4511>`__","Inconsistency between the deduction guide of ``std::mdspan`` taking ``(data_handle_type, mapping_type, accessor_type)`` and the corresponding constructor","2026-03 (Croydon)","","","`#189860 <https://github.com/llvm/llvm-project/issues/189860>`__",""
+"`LWG4511 <https://wg21.link/LWG4511>`__","Inconsistency between the deduction guide of ``std::mdspan`` taking ``(data_handle_type, mapping_type, accessor_type)`` and the corresponding constructor","2026-03 (Croydon)",|Complete|,23,"`#189860 <https://github.com/llvm/llvm-project/issues/189860>`__",""
 "`LWG4512 <https://wg21.link/LWG4512>`__","The ``system_encoded_string()`` and ``generic_system_encoded_string()`` member functions of ``std::filesystem::path`` are misnamed","2026-03 (Croydon)","","","`#189861 <https://github.com/llvm/llvm-project/issues/189861>`__",""
 "`LWG4514 <https://wg21.link/LWG4514>`__","Missing absolute value of ``init`` in ``vector_two_norm`` and ``matrix_frob_norm``","2026-03 (Croydon)","","","`#189862 <https://github.com/llvm/llvm-project/issues/189862>`__",""
 "`LWG4517 <https://wg21.link/LWG4517>`__","``data_member_spec`` should throw for *cv*-qualified unnamed bit-fields","2026-03 (Croydon)","","","`#189863 <https://github.com/llvm/llvm-project/issues/189863>`__",""
diff --git a/libcxx/include/__mdspan/mdspan.h b/libcxx/include/__mdspan/mdspan.h
index 024c1002b1a09..54685b56a76ff 100644
--- a/libcxx/include/__mdspan/mdspan.h
+++ b/libcxx/include/__mdspan/mdspan.h
@@ -313,7 +313,7 @@ mdspan(_ElementType*, const _MappingType&)
     -> mdspan<_ElementType, typename _MappingType::extents_type, typename _MappingType::layout_type>;
 
 template <class _MappingType, class _AccessorType>
-mdspan(const typename _AccessorType::data_handle_type, const _MappingType&, const _AccessorType&)
+mdspan(typename _AccessorType::data_handle_type, const _MappingType&, const _AccessorType&)
     -> mdspan<typename _AccessorType::element_type,
               typename _MappingType::extents_type,
               typename _MappingType::layout_type,
diff --git a/libcxx/include/mdspan b/libcxx/include/mdspan
index 618f6927bf7a1..d46f87cb0f014 100644
--- a/libcxx/include/mdspan
+++ b/libcxx/include/mdspan
@@ -431,7 +431,7 @@ namespace std {
                 typename MappingType::layout_type>;
 
   template<class MappingType, class AccessorType>
-    mdspan(const typename AccessorType::data_handle_type&, const MappingType&,
+    mdspan(typename AccessorType::data_handle_type, const MappingType&,
            const AccessorType&)
       -> mdspan<typename AccessorType::element_type, typename MappingType::extents_type,
                 typename MappingType::layout_type, AccessorType>;
diff --git a/libcxx/test/std/containers/views/mdspan/mdspan/deduction.pass.cpp b/libcxx/test/std/containers/views/mdspan/mdspan/deduction.pass.cpp
index 8b4d24d2a398d..762841016e29e 100644
--- a/libcxx/test/std/containers/views/mdspan/mdspan/deduction.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/mdspan/deduction.pass.cpp
@@ -46,7 +46,7 @@
 //                typename MappingType::layout_type>;
 //
 //  template<class MappingType, class AccessorType>
-//    mdspan(const typename AccessorType::data_handle_type&, const MappingType&,
+//    mdspan(typename AccessorType::data_handle_type, const MappingType&,
 //           const AccessorType&)
 //      -> mdspan<typename AccessorType::element_type, typename MappingType::extents_type,
 //                typename MappingType::layout_type, AccessorType>;
@@ -167,6 +167,11 @@ constexpr bool test() {
   float a[12];
   ASSERT_SAME_TYPE(decltype(std::mdspan(a)), std::mdspan<float, std::extents<size_t, 12>>);
 
+  float* volatile p = a;
+  ASSERT_SAME_TYPE(decltype(std::mdspan(
+                       p, std::layout_right::mapping<std::extents<std::size_t, 1>>{}, std::default_accessor<float>{})),
+                   std::mdspan<float, std::extents<std::size_t, 1>, std::layout_right, std::default_accessor<float>>);
+
   return true;
 }
 int main(int, char**) {

>From 7a21c1c761b7894d22797ba01d193fa504debba1 Mon Sep 17 00:00:00 2001
From: eiytoq <eiytoq at outlook.com>
Date: Tue, 14 Apr 2026 14:00:53 +0800
Subject: [PATCH 2/2] Addressed comment

Co-authored-by: A. Jiang <de34 at live.cn>
---
 libcxx/docs/Status/Cxx2cIssues.csv | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/docs/Status/Cxx2cIssues.csv b/libcxx/docs/Status/Cxx2cIssues.csv
index 381ef0bc72de3..1653562724982 100644
--- a/libcxx/docs/Status/Cxx2cIssues.csv
+++ b/libcxx/docs/Status/Cxx2cIssues.csv
@@ -315,7 +315,7 @@
 "`LWG4504 <https://wg21.link/LWG4504>`__","Wording problem in ``{simple_}counting_scope``","2026-03 (Croydon)","","","`#189857 <https://github.com/llvm/llvm-project/issues/189857>`__",""
 "`LWG4506 <https://wg21.link/LWG4506>`__","``source_location`` is explicitly unspecified if is constexpr or not","2026-03 (Croydon)","","","`#189858 <https://github.com/llvm/llvm-project/issues/189858>`__",""
 "`LWG4510 <https://wg21.link/LWG4510>`__","Ambiguity of ``std::ranges::advance`` and ``std::ranges::next`` when the difference type is also a sentinel type","2026-03 (Croydon)","","","`#189859 <https://github.com/llvm/llvm-project/issues/189859>`__",""
-"`LWG4511 <https://wg21.link/LWG4511>`__","Inconsistency between the deduction guide of ``std::mdspan`` taking ``(data_handle_type, mapping_type, accessor_type)`` and the corresponding constructor","2026-03 (Croydon)",|Complete|,23,"`#189860 <https://github.com/llvm/llvm-project/issues/189860>`__",""
+"`LWG4511 <https://wg21.link/LWG4511>`__","Inconsistency between the deduction guide of ``std::mdspan`` taking ``(data_handle_type, mapping_type, accessor_type)`` and the corresponding constructor","2026-03 (Croydon)","|Complete|","18","`#189860 <https://github.com/llvm/llvm-project/issues/189860>`__",""
 "`LWG4512 <https://wg21.link/LWG4512>`__","The ``system_encoded_string()`` and ``generic_system_encoded_string()`` member functions of ``std::filesystem::path`` are misnamed","2026-03 (Croydon)","","","`#189861 <https://github.com/llvm/llvm-project/issues/189861>`__",""
 "`LWG4514 <https://wg21.link/LWG4514>`__","Missing absolute value of ``init`` in ``vector_two_norm`` and ``matrix_frob_norm``","2026-03 (Croydon)","","","`#189862 <https://github.com/llvm/llvm-project/issues/189862>`__",""
 "`LWG4517 <https://wg21.link/LWG4517>`__","``data_member_spec`` should throw for *cv*-qualified unnamed bit-fields","2026-03 (Croydon)","","","`#189863 <https://github.com/llvm/llvm-project/issues/189863>`__",""



More information about the libcxx-commits mailing list