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

qHash(Enum, size_t) may call an unexpected overload

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P1: Critical P1: Critical
    • 6.5.0 Beta1
    • 6.0, 6.1, 6.2, 6.3, 6.4, 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

      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.

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes