Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-130643

std::to_address doesn't work for QList::iterator

    XMLWordPrintable

Details

    • Linux/X11
    • b8c879f27 (dev), 6535b6d5f (6.8)
    • Foundation Sprint 118

    Description

      The following code fails to compile (at least on GCC 9.4 and in C++20 mode):

      QList<int> l;
      assert(std::to_address(l.begin()) == l.data());
      

      GCC says

      /usr/include/c++/9/bits/ptr_traits.h: In instantiation of ‘struct std::pointer_traits<QList<int>::iterator>’:
      /usr/include/c++/9/bits/ptr_traits.h:171:54:   required by substitution of ‘template<class _Ptr> constexpr decltype (std::pointer_traits<_Ptr>::to_address(__ptr)) std::__to_address(const _Ptr&) [with _Ptr = QList<int>::iterator]’
      /usr/include/c++/9/bits/ptr_traits.h:207:31:   required from ‘constexpr auto std::to_address(const _Ptr&) [with _Ptr = QList<int>::iterator]’
      /usr/include/c++/9/bits/ptr_traits.h:119:21: error: static assertion failed: pointer type defines element_type or is like SomePointer<T, Args>
        119 |       static_assert(!is_same<element_type, __undefined>::value,
            |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      

      It works for l.rbegin(), though.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              mmutz Marc Mutz
              mmutz Marc Mutz
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There is 1 open Gerrit change