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

qHash(Enum, size_t) may call an unexpected overload

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 6.5.0 Beta1
    • 6.0, 6.1, 6.3, 6.4, 6.2, 6.5
    • Core: Other
    • None
    • All
    • 13
    • fb4bc5fa26 (qt/qtbase/dev) fb4bc5fa26 (qt/tqtc-qtbase/dev), b2f3af4db (6.4)
    • Foundation Sprint 66, Foundation Sprint 67, Foundation Sprint 68

    Description

      During the investigation of QTBUG-106219 it was discovered that certain include-ordering has an effect on qHash(Enum, size_t).

      If QKeySequence was included before qhashfunctions.h then the compiler would call a catch-all overload of qHash meant to allow old qHash implementations without a seed parameter to be called seamlessly without having to update the implementation. This overload xor's the seed with the result of qHash(Enum, 0) before returning it.

      Usually qHash(Enum, size_t) will call qHash(int, size_t), and the biggest issue is that these two paths generate different hashes. So, as observed in QTBUG-106219, one could have a QHash container in one file and insert entries with one hash. Then, when the QHash container is moved and used in another file we end up trying to look up the key by a different hash, meaning we don't find any matches.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-107033
          # Subject Branch Project Status CR V

          Activity

            People

              peppe Giuseppe D'Angelo
              manordheim Mårten Nordheim
              Vladimir Minenko Vladimir Minenko
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There is 1 open Gerrit change