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

Preprogam QHashPrivate::Span::Entry as a union for Qt 7, bootstrap, to avoid laundering on every node access

XMLWordPrintable

      See comments on QTBUG-111043 for an analysis.

      TL;DR:

      • Entry uses an ex-std::aligned_storage_t to store either a Node or a uchar
      • so it should be a union, and then std::launder()'ing wouldn't be necessary on each node access
      • making it a union will = delete its dtor if Node (~ pair<Key,Value>) is not std::is_trivially_destructible
      • Entry doesn't know whether it contains a Node or not (that info is in Span::offsets), so we can't add a user-defined ~Entry()
      • the existing code uses new[] and delete[] to (de)allocate Span::entries, so we need Entry to be std::destructible
      • we cannot use malloc() and free() instead because old code will continue to use new[] and delete[], and mixing the two is UB

      In order to avoid forgetting this come Qt 7, we should pre-program for QT_BOOTSTRAP || QT_VERSION_CHECK(7, 0, 0).

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

            cnn Qt Core & Network
            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:
              Resolved:

                There are no open Gerrit changes