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

QAssociativeIterable access always successful if container has zero key

    XMLWordPrintable

Details

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

    Description

      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
      

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes