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

tst_QItemSelectionModel: QStreamHelper::create() stores address of local variable in QModelInde::model()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.15, 6.2, 6.5, 6.6.0 Beta1
    • Core: Item Models
    • None
    • All

      GCC 13 warns:

      tst_qitemselectionmodel.cpp: In function ‘Qt6::QDataStream& Qt6::operator>>(QDataStream&, QModelIndex&)’:
      tst_qitemselectionmodel.cpp:138:35: warning: storing the address of local variable ‘helper’ in ‘*output.Qt6::QModelIndex::m’ [-Wdangling-pointer=]
        138 |     output = QStreamHelper::create(r, c, reinterpret_cast<void *>(ptr));
            |              ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      tst_qitemselectionmodel.cpp:105:23: note: ‘helper’ declared here
        105 |         QStreamHelper helper;
            |                       ^~~~~~
      tst_qitemselectionmodel.cpp:105:23: note: ‘output’ declared here
      

      Indeed, GCC is correct:

          static QModelIndex create(int row = -1, int column = -1, void *data = 0)
          {
              QStreamHelper helper;
              return helper.QAbstractItemModel::createIndex(row, column, data);
          }
      

      This stores the address of the local object helper as model() in the return value.

      Was static QStreamHelper helper intended?

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

            dfaure_kdab David Faure
            mmutz Marc Mutz
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes