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

QAssociativeIterable access always successful if container has zero key

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P1: Critical P1: Critical
    • None
    • 6.0.0 Beta1
    • None
    • 37c7ef4f4a8478e94eaf0af5b40c279c476fa561 (qt/qtbase/dev)

      Given this code:

      #include <QtCore/QDebug>
      #include <QtCore/QAssociativeIterable>
      #include <QtCore/QVariant>
      #include <QtCore/QMap>
      
      int main(int, char**)
      {
          auto container = QMap<int, int>();
      
          // Add a key with value `0`. Other values do not cause the bug
          container[0] = 1;
      
          auto containerVariant = QVariant::fromValue(container);
          auto iter = containerVariant.value<QAssociativeIterable>();
          auto f = iter.constFind(QStringLiteral("anything"));
          qDebug() << "Itercm" << (f != iter.constEnd());
      
        return 0;
      }
       

      we get this output:

      Itercm true
      

       

      but we expect
       

      Itercm false
      

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

            ulherman Ulf Hermann
            steveire Stephen Kelly (Personal)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes