Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15, 6.2, 6.5, 6.6.0 Beta1
-
None
Description
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?