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

REG 5->6: QVector size() does not reach capacity() before reallocating

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P1: Critical
    • Resolution: Unresolved
    • Affects Version/s: 6.0, 6.1, 6.2
    • Fix Version/s: None
    • Labels:
      None

      Description

      This code regressed in Qt 6:

          QVector<int> v;
          v.resize(4);
          v.erase(v.begin());
          while (v.size() < v.capacity()) {
              v.push_back(0);
          }
      

      The while loop never terminates; the vector is reallocated too early, when size() == capacity() - 1, and keeps getting reallocated like that.

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              thiago Thiago Macieira
              Reporter:
              peppe Giuseppe D'Angelo
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There is 1 open Gerrit change