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

QMultiMap::upperBound() const iterator issue

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Invalid
    • Affects Version/s: 6.2.0 Alpha
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      All

      Description

      using TestMultiMap = QMultiMap<int, QByteArray>;
      
      void test(TestMultiMap m)
      {
          for (auto it = m.cbegin(), end = m.cend(); it != end; ) {
              const auto &key = it.key();
              TestMultiMap::const_iterator keyEnd = m.upperBound(key);
              const auto count = std::distance(it, keyEnd);
              qDebug() << it.key() << "count=" << count;
              for ( ; it != keyEnd; ++it)
                  qDebug() << it.key() << it.value();
          }
      }
      

      produces a hang in std::distance() with g++ 9.3.0.1 and a "mismatched set/hash" iterator error with MSVC (5.15: crash). When changing the function to take a (const TestMultiMap &m), the code works as expected.

      It is weird since TestMultiMap::const_iterator keyEnd = m.upperBound(key) should produce a proper const iterator.

        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:
            kleint Friedemann Kleint
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes