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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P1: Critical P1: Critical
    • None
    • 6.0, 6.1, 6.2
    • None

      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.

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

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

              Created:
              Updated:

                There are no open Gerrit changes