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

Compile error when adding QList::const_iterator and std::ptrdiff_t

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 6.2.1, 6.3.0 Alpha
    • 6.1.2
    • Core: Other
    • None
    • macOS 11.2.3
    • macOS
    • 878b2047b52c93e904eb46ef1044819a8b5614ab (qt/qtbase/dev) 8b65905e4b8c12040373cc36ec29dbe2861c24a9 (qt/qtbase/6.2)

    Description

      The following code compiles with Qt 5.15 but fails to compile with Qt 6.1.2:

      auto foo(QList<int>::const_iterator p, std::ptrdiff_t n) {
          return p + n;
      }
      

      The error is:

      test.cpp:9:14: error: use of overloaded operator '+' is ambiguous (with operand types 'QList<int>::const_iterator' and 'ptrdiff_t' (aka 'long'))
          return p + n;
                 ~ ^ ~
      Qt/6.1.2/macos/lib/QtCore.framework/Headers/qlist.h:198:31: note: candidate function
              inline const_iterator operator+(qsizetype j) const { return const_iterator(i+j); }
                                    ^
      test.cpp:9:14: note: built-in candidate operator+(const int *, long)
          return p + n;
                   ^
      

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            paulaltin Paul Altin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes