[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 Mar 9 01:32:39 PDT 2026


================
@@ -283,7 +304,18 @@ template <class _ValueType,
 #  endif
           >
 class __deque_iterator {
-  typedef _MapPointer __map_iterator;
+  using __map_iterator _LIBCPP_NODEBUG = __get_deque_map_iterator<_ValueType, _MapPointer>;
----------------
philnik777 wrote:

```suggestion
  using __map_iterator _LIBCPP_NODEBUG = __rebind_pointer_t<__rebind_pointer_t<_Pointer, __remove_cv_t<_ValueType> >, _Pointer>;
```
This isn't quite equivalent, but I'm not convinced the `const` int `T* const*` gains us much except metaprogramming complexity. Actually, I don't think there is a reason to ever not have that `const`, since the iterator should never modify the map, so I think we should be able to rebind to `const _Pointer` unconditionally.

What I mean by "build up the type" is constructing it from the other parts we have instead of decomposing the `_MapPointer` and trying to stitch it back together.

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


More information about the libcxx-commits mailing list