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

QMultiHash::operator==() returns false for two empty hashes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 6.0.0 Alpha
    • None
    • ef1905aebc4c4961c859bd781398dc6cea89d3a0 (qt/qtbase/dev)

    Description

      Noticed while fixing QtPIM unit tests to work with Qt6.

      //Qt
      #include <QtCore/QCoreApplication>
      #include <QtCore/QVariantMap>
      #include <QtCore/QString>
      #include <QtCore/QTimer>
      #include <QtCore/QObject>
      #include <QMultiHash>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication app(argc, argv);
          QMultiHash<QString,QString> a, b;
      
          qWarning() << "A == B ? " << (a == b); // expect true, actual true
      
          a.insert(QStringLiteral("1"), QStringLiteral("1.a"));
          a.insert(QStringLiteral("1"), QStringLiteral("1.b"));
      
          qWarning() << "A == B ? " << (a == b); // expect false, actual false
      
          a.remove(QStringLiteral("1"));
      
          qWarning() << "A.isEmpty() -> " << a.isEmpty(); // expect true, actual true
          qWarning() << "B.isEmpty() -> " << b.isEmpty(); // expect true, actual true
      
          qWarning() << "A -> " << a; // QMultiHash()
          qWarning() << "B -> " << b; // QMultiHash()
      
          qWarning() << "A == B ? " << (a == b); // expect true, actual false
      
          return 0;
      }
      

      With Qt5.12.9 the final qWarning() prints "true", with Qt6 it prints "false".

      Attachments

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

        Activity

          People

            laknoll Lars Knoll
            chrisadams Christopher Adams
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes