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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 6.1.2
    • Fix Version/s: 6.2.1, 6.3.0 Alpha
    • Component/s: Core: Other
    • Labels:
      None
    • Environment:
      macOS 11.2.3
    • Platform/s:
      macOS
    • Commits:
      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

            Assignee:
            thiago Thiago Macieira
            Reporter:
            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