[libcxx-commits] [libcxx] [libc++] Fix strict aliasing violation for `deque::const_iterator` (PR #136067)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 15 02:47:14 PST 2025


================
@@ -441,6 +463,11 @@ private:
       : __m_iter_(__m),
         __ptr_(__p) {}
 
+  template <bool _IsSamePointer = is_same<_MapPointer, __map_iterator>::value, __enable_if_t<!_IsSamePointer, int> = 0>
+  _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(_MapPointer __m, pointer __p) _NOEXCEPT
+      : __m_iter_(__m ? pointer_traits<__map_iterator>::pointer_to(*__m) : nullptr),
+        __ptr_(__p) {}
+
----------------
philnik777 wrote:

Why is this required? Can't we just use the constructor above and update any places where we give `__deque_iterator` a `const` version?

https://github.com/llvm/llvm-project/pull/136067


More information about the libcxx-commits mailing list