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

The qHash() one-arg-to-two-arg adapter matches too eagerly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.6.0 Beta4
    • None

      While fixing QTBUG-116076, I found out that the qHash() adapter matches not only qfloat16, but also all concrete pointer types. Deprecating it, I get warnings for, among other things:

      • QPersistentModelIndexData *
      • QThreadPoolThread *
      • unsigned char *
      • Unknown macro: {[QAbstractAnimation *}

        }

      • bool
      • QObject *
      • QLoggingCategory *

      The problem is that we can't change the hash calculation, as the function is inline. So the following solutions don't apply:

      • constrain the adapter further, to include !is_pointer_v<T> and !is_integral_v<T>, because that would make it use qHash(const T*, size_t), which doesn't xor in seed.
      • add a qHash(T*, size_t), hopefully a better match for pointer-to-non-const objects, but that would mean we need to be consistent with both existing qHash(const T*, size_t) as well as the adapter, and they're not consistent with each other

      For the time being, it seems we can't do better than to wait this out for Qt 7?

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

            thiago Thiago Macieira
            mmutz Marc Mutz
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes